;
//var manuscriptSystem = function() {
cmedit.ManuscriptSystem = (function($, window, document) {
    var thisContext;
    var resourceType = "1";
    var privilegeInfo = JSON.parse(window.sessionStorage.getItem(cmedit.global.privilegeInfo));
    var leftType = "1";
    var mainIsDeleted = 1;
    var tabActivelist = [];
    var loadTimeout = cmedit.global.loadTimeout;
    var privilegeIds = window.sessionStorage.getItem(cmedit.global.privilegeIds);
    var userColumnIds = window.sessionStorage.getItem(cmedit.global.userColumnIds);
    var allColumnIds = window.sessionStorage.getItem(cmedit.global.allColumnIds);
    var columnInfo = JSON.parse(window.sessionStorage.getItem(cmedit.global.columnInfo));
    var allColumnInfo = JSON.parse(window.sessionStorage.getItem(cmedit.global.allColumnInfo));
    var bigColumnId = window.sessionStorage.getItem(cmedit.global.bigColumnId);
    var creImportTaskFlag = window.sessionStorage.getItem(cmedit.global.creImportTaskFlag);
//    var distributeSecretFlag = window.parent.sessionStorage.getItem("distributeSecretFlag");
    var tenantId = window.localStorage.getItem("tenantId");
    var userId = window.localStorage.getItem("userId");
    var token = window.localStorage.getItem("token");
    var checkAllStatus = false; // (版本对比模态框)全选状态
    var topUtil; //顶层工具类
    var imgList = {};
    var selectIds = [];
    var selectColumnIds = [];
    var listTotalCount;
    var listPageSize;
    var userId;
    var userName;
    var token;
    var tenantId;
    var orderName = '';
    var pageNow;
    var orderDirection = '';
    var isCheckCopy = '';
    var isMoudId="";
    var channelnewid="";
    var ManuscriptSystemClass = function() {

    }
    ManuscriptSystemClass.prototype = {
        constructor: ManuscriptSystemClass,

        finalOptionList: [],

        initHeader: function() {

            if (cmedit.global.isPublish) {
                // 优先动态加载css和js后执行页面初始化方法
                $.getScript(cmedit.global.getPortalWeb() + 'static/scripts/utils/headerPlugin.min.js', function() { //加载js,成功后，并执行回调函数  ; 
                    //向域对象下存储portalPath地址，以便在headerPlugin插件中使用
                    window.sessionStorage.setItem("portalPath", cmedit.global.portalPath);
                    var systsemCmedit = cmedit.global.getAppByCode(cmedit.global.system_cmedit_cms_id, window.localStorage.getItem("tenantId"));
                    window.sessionStorage.setItem("systsemCmedit", JSON.stringify(systsemCmedit));
                    // 查询版本信息
                    topUtil.ajaxRequest({
                        async: false,
                        url: cmedit.global.cmsPath + "UserInfoController/getModuleInfo",
                        type: 'GET',
                        success: function(data) {
                            if (data.status == true || data.status == 'true') {
                            	var cms_version = data.data.version;
                                var cms_updateTime = data.data.updateTime;
                                if (cmedit.global.isNotEmpty(cms_version)) {
                                    cmedit.global.version = cms_version + "[server]" + " - " + cmedit.global.updatetime.replace(/-/g, "") + "[web]";
                                }
                                if (cmedit.global.isNotEmpty(cms_updateTime)) {
                                    cmedit.global.updatetime = cms_updateTime + "[server]" + " - " + cmedit.global.updatetime + "[web]";
                                }
                                $.initHeader({
                                    "divId": 'manuHeader',
                                    "highLight": systsemCmedit.appCode, //高亮应用id
                                    "aboutInfo": [{ //需要在导航栏中关于模块要展现的信息，无属性则不展现
                                            "aboutName": "版本信息",
                                            "aboutCode": "Vesion",
                                            "aboutValue": cmedit.global.version
                                        },
                                        { //需要在导航栏中关于模块要展现的信息
                                            "aboutName": "升级时间",
                                            "aboutCode": "UpdateTime",
                                            "aboutValue": cmedit.global.updatetime
                                        }
                                    ]
                                });

                            } else {
                                $.notify(data.msg);
                            }
                        }
                    });
                });
            }

        },
        /**
         * 真正的初始化方法
         */
        init: function() {
            thisContext = this;
            topUtil = window.parent.cmedit.global;
            if (!allColumnIds) {
                window.location.href = "../../loginBycas.html";
                return;
            }
            
            var loginModel = window.localStorage.getItem("login_casData");
            if (!loginModel) {
                loginModel = cmedit.global.getUserInfo(cmedit.global.portalPath, window.localStorage.getItem("portalKey")).loginModel;
            } else {
                loginModel = JSON.parse(loginModel);
            }
            
            userId = loginModel.userId; //用户userID
            token = loginModel.token; //用户token
            userName = loginModel.userName; //用户名
            var workNo = loginModel.workNo; //用户workNo
            tenantId = loginModel.tenantId; //用户租户id
            var cloudType = loginModel.cloudType; //是否是公有云

            window.sessionStorage.setItem("userId", userId);
            window.sessionStorage.setItem("token", token);
            window.sessionStorage.setItem("userName", userName);
            window.sessionStorage.setItem("workNo", workNo);
            window.sessionStorage.setItem("tenantId", tenantId);
            window.sessionStorage.setItem("cloudType", cloudType);
            
            thisContext.initViewStyle();
            //thisContext.initPrivilege();
            thisContext.initColumn();
            thisContext.initData();
            thisContext.initEvent();
            thisContext.initExternal();
            thisContext.initHeader();
        },
        
	    /**
         * 退出登录
         */
        loginOutManuscript : function(){
        	
    	  var gatewayAddress = window.localStorage.getItem("fastAddress");
          var loginModel = JSON.parse(window.localStorage.getItem("login_casData"));
          window.sessionStorage.clear(); //当前标签页的所有sessionStorage均可清除
          var cloudType = loginModel.cloudType;
          if (!loginModel.isSuperAdmin) { // 如果当前不是超级管理员
              var logoutAddress = gatewayAddress + "casLogout?service=";
              var service = gatewayAddress + "dyportalserver/loginBycas";
              window.top.location.href = logoutAddress + service; //返回cas登录页
          } else {
              window.top.location.href = dyportal_server.replace("dyportalserver/", "dyportalweb/dyLogin.html");
          }
              
        },
        /**
         * 初始化页面视图
         */
        initViewStyle: function() {
            // 如果用户没有稿件编辑权限，禁用复制、删除、新增按钮
            if (privilegeIds.indexOf(cmedit.global.privilegeWritescripts) == -1) {
                $("#createButton").hide();
            }
            $("#myManuscriptMenu").css('display', 'inline');
            $("#allManuscriptMenu").css('display', 'inline');
            // 如果用户没有成品稿库权限，禁用成品稿库任务页
            if (privilegeIds.indexOf(cmedit.global.privilegeFinished) != -1) {
                $("#finishedManuscriptMenu").css('display', 'inline');
            }
            // 签发安全开关开启
//            if(distributeSecretFlag == '1'){
//            	$("#finishedManuscriptMenu").css('display', 'none');
//            }
            // 如果用户没有审核权限，禁用审核任务页
            if (privilegeIds.indexOf(cmedit.global.privilegeAuditscripts) != -1) {
                $("#censorMenu").css('display', 'inline');
            }
            // 如果用户没有签发权限，禁用签发任务页
            if (privilegeIds.indexOf(cmedit.global.privilegeDistribute) != -1) {
                $("#distributeMenu").css('display', 'inline');
            }
            // 如果用户没有下载权限，禁用下载按钮
            if (privilegeIds.indexOf(cmedit.global.privilegeExportword) != -1) {
                $("#downloadMenu").css('display', 'inline');
            } else {
                $("#downloadButton").hide();
            }
            $("#recycleMenu").css('display', 'inline');
            /*$('.re-content').css('height',$(document).height()-110+'px');*/
            $('.re_contleft .slimScrollDiv').css('height', $(document).height() - 136 + 'px');
            $('.myManulistContents').css('height', $('.portlet-body').innerHeight() - 40 + 'px');
            //            $('.line-body').css('height',$('.cont_container').innerHeight()-203+'px');
            //
            //            /*修改滚动条样式*/
            //            var linescroll_height=$('.line-body').height();
            //            thisContext.scrollType('.line-body',linescroll_height);

            var versionscroll_height = $('.versionContainer').css('maxHeight');
            thisContext.scrollType('.versionContainer', versionscroll_height);
        },
        /**
         * 时间排序
         */
        orderby: function(id, orderDirectionName) {
            orderName = id;
            orderDirection = orderDirectionName;
            thisContext.initData(pageNow);
        },
        /**
         * 初始化数据
         */
        initData: function(_currentPage,_pageSize) {
            window.parent.cmedit.ManuscriptSystem.updatePortalStorageExpireTime();
            //清空终审意见session;
            for (var i = 0; i < cmedit.ManuscriptSystem.finalOptionList.length; i++) {
                window.sessionStorage.removeItem("FINALOPTION_" + cmedit.ManuscriptSystem.finalOptionList[i]);
            }
            cmedit.ManuscriptSystem.finalOptionList = [];
            //        	$('#allSelected').prop('checked',false);
            //        	$('#manuscripyBody').html(cmedit.global.loaderHtml);
            var $tableid = $('#manulistTable');
            var url = cmedit.global.cmsPath + "ManuscriptMainController/getManuscriptByPage";
            var gc = JSON.parse(window.sessionStorage.getItem(cmedit.global.cmeditList));
            //判断权限中是否有终审浏览权限，如果有，则显示终审浏览
            if (privilegeIds.indexOf(cmedit.global.privilegeFinalcensor) != -1) {
                gc = JSON.parse(window.sessionStorage.getItem(cmedit.global.cmeditFinal));
                resourceType = '0';
                document.getElementById("zhiding").style.display = "none";
            }
            var cmeditList = JSON.parse(window.sessionStorage.getItem(cmedit.global.cmeditTypes));
            var hasCheckbox = true;
            selectIds = [];
            if ($('#searchContent').val() != null && $('#searchContent').val() != '') {
                var title = $('#searchContent').val();
            } else {
                var title = '';
            }
            //          if($('#endTime').val()!=null && $('#endTime').val()!=''){
            if (($('#endTime').val() != null && $('#endTime').val() != '') || ($('#startTime').val() != null && $('#startTime').val() != '')) {
                var dateranges = $("#startTime").val() + " - " + $("#endTime").val();
            } else {
                var dateranges = '';
            }
            var currentPage = _currentPage ? _currentPage : 1;
            var pageSize =_pageSize ? _pageSize : 10;

            var states = $("#mainStatus button[class*='active']").attr("states");
            var mainIsOriginal = $("#mainIsOriginal button[class*='active']").attr("states");
            resourceType = resourceType ? resourceType : '1';
            //判断权限中是否有终审浏览权限，如果有，则显示终审浏览
            /*for(var i = 0;i<privilegeInfo.length;i++ ){
				if(privilegeInfo[i].id == "PID_CMEDIT_FINALCENSOR"){
					resourceType = '0';
					document.getElementById("zhiding").style.display = "none";
				}
			}*/
            mainIsDeleted = mainIsDeleted ? mainIsDeleted : '1';
            var columnId = $("#preReportColumn").val() != "" ? $("#preReportColumn").val() : "";
            var queryParams = {
                resourceType: resourceType,
                mainIsDeleted: mainIsDeleted,
                userColumnIds: userColumnIds,
                mainHeader: title,
                mainStatus: states,
                columnId: columnId,
                dateranges: dateranges,
                mainIsOriginal: mainIsOriginal,
                mainType: 0, //CMS稿
                currentPage:currentPage,
                pageSize:pageSize
            };
            var tableParams = {
                $tableid: $tableid,
                url: url,
                gc: gc,
                hasCheckbox: hasCheckbox,
                tenantId: tenantId,
                userId: userId,
                token: token,
                cmeditList: cmeditList,
                resourceType: "myManulist",
                callBackRender: function() {
                    // 如果用户没有编辑权限，禁用复制操作按钮
                    if (privilegeIds.indexOf(cmedit.global.privilegeWritescripts) == -1) {
                        $(".operateCopyItem").css('display', 'none');
                        $(".lineTip").css('display', 'none');
                    }
                    //如果竟然还没有删除全部权限，那就连删除一切干掉
                    if (privilegeIds.indexOf(cmedit.global.privilegeDelFinishscripts) == -1 && 
                    		privilegeIds.indexOf(cmedit.global.privilegeDelallscripts) == -1) {
//                    	$(".operateDeleteItem").css('display', 'none');
                    	$("#deleteButton").hide();
//                    	$("#operateButton").css('display', 'none');
                    }
                },
                callBackLoadData:function(start,size){
                	thisContext.initData(start,size);
                }
            };
            console.log('tableParams:' + tableParams);
            TableInit(tableParams, queryParams);
        },
        /**
         * 生成微信二维码
         */
        wechatShow: function(mainGuid) {
        	$("#wechatImg").hide();
            if (topUtil.isNotEmpty(mainGuid)) {
                //获取通稿前端地址
                var appUrl = window.location.protocol + '//' + window.location.host + "/gateway/dywebpageweb/"
                //微信二维码预览页面地址
                var previewUrl = appUrl + "views/manuscript/manuscript_preview.html";
                topUtil.ajaxRequest({
                    type: "post",
                    async: true,
                    dataType: "json",
                    url: cmedit.global.cmsPath + "CmsNewTargetController/weChatQRCode",
                    data: {
                        mainGuid: mainGuid,
                        previewUrl: previewUrl
                    },
                    success: function(data) {
                        if (data.status) {
                            var imgUrl = "data:image/jpeg;base64," + data.data;
                            var html = '<img style="width:100%;height:100%" src=\'' + imgUrl + '\'>';
                            $("#wechatQrCode").html(html);
                            $("#wechatImg").show();
                        } else {
                            $.notify("生成微信二维码失败");
                        }
                    }
                });
            }
        },
        popoverBox: function(obj, mainGuid) {
            var thisObj = $(obj).parent().find('.popoverimg');
            var ulstring = thisContext.getFinalOpition(mainGuid);
            var timer = null,
                popBox = thisObj.next(),
                imgtop = thisObj.offset().top,
                imgLeft = thisObj.position().left;
            var maxTop = $(window).height() - 240,
                theadTop = $('.fixed-table-header').offset().top + 155,
                boxWidth = $(".popover-box").outerWidth(),
                arrowWidth = $(".popover-arrow").outerWidth();
            var boxLeft = imgLeft - boxWidth * 0.85;
            console.log("imgtop:" + imgtop + " maxTop:" + maxTop + " theadTop:" + theadTop);
            // console.log(" boxLeft"+boxLeft );
            // thisObj.next().offset({left: boxLeft});
            thisObj.next().css('left', boxLeft + 'px');
            // console.log(thisObj.next().offset().left);            
            thisObj.next().find('.popover_content').html(ulstring);
            if (imgtop > maxTop && imgtop > theadTop) {
                popBox.addClass('popbox-transY');
                popBox.children('div:first-child').removeClass('popover-arrow-up').addClass('popover-arrow-down');

            } else {
                popBox.removeClass('popbox-transY');
                popBox.children('div:first-child').removeClass('popover-arrow-down').addClass('popover-arrow-up');
            }
            $(".popover-box").hide();
            popBox.show();
            thisObj.on("mouseout", function() {
                timer = setTimeout(function() {
                    popBox.hide();
                }, 500);
            });
            thisObj.prev().on("mouseout", function() {
                timer = setTimeout(function() {
                    popBox.hide();
                }, 500);
            });
            $(".popover-box").on("mouseover", function() {
                clearTimeout(timer);
                $(this).show();
            }).on("mouseout", function() {
                $(this).hide();
            });
        },

        /**
         * 向融云获取查重信息
         */
        repeatModalShow: function(obj, mainGuid) {
            var userColumnIds = window.parent.sessionStorage.getItem(cmedit.global.userColumnIds);
            var postData = {
                mainGuid: mainGuid,
                userColumnIds: userColumnIds,
                mainType: 0
            }

            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "RonYunController/getOriginalLocal",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        var recommendList = data.data.resources;
                        $("#repeatMessage").html("");
                        var html = '';
                        if (recommendList.length > 0) {
                            var listData = {
                                list: recommendList
                            }
                            html = template('ryRepetitionListHtmls', listData);
                        } else {
                            html = '<li><p class="noResults">暂无数据</p></li>';
                        }
                        $("#repeatMessage").html(html);
                        $('#repeatModal').modal('show');
                    } else {
                        $("#repeatMessage").html("");
                        $('#repeatModal').modal('show');
                        $.notify(data.msg);
                    }
                }
            });
        },
        
        repeatModalHide:function(){
        	$('#repeatModal').modal('hide');
        },
        
        /**
         * 获取终审意见
         */
        getFinalOpition: function(mainGuid) {
            var sessionOption = window.sessionStorage.getItem("FINALOPTION_" + mainGuid);
            var returnHtml = '';
            if (sessionOption) {
                returnHtml = sessionOption;
            } else {
                var postData = {
                    mainGuid: mainGuid
                }
                window.parent.cmedit.ManuscriptSystem.updatePortalStorageExpireTime();
                topUtil.ajaxRequest({
                    type: "post",
                    async: false,
                    dataType: "json",
                    url: cmedit.global.cmsPath + "ManuscriptMainController/getManuscriptFinalOperate",
                    data: postData,
                    success: function(data) {
                        if (data.status) {
                            console.log(data);
                            if (data.data != null && data.data.length > 0) {
                                var finalOption = data.data[0];
                                returnHtml = '<p>' + finalOption.clbUserName + ' 审批意见' + '</p>';
                                if (finalOption.clbCensorOpinion) {
                                    returnHtml += '<p>' + finalOption.clbCensorOpinion + '</p>';
                                } else {
                                    returnHtml += '<p>无审核意见</p>';
                                }
                            } else {
                                returnHtml += '<p>无审核意见</p>';
                            }
                            window.sessionStorage.setItem("FINALOPTION_" + mainGuid, returnHtml);
                            cmedit.ManuscriptSystem.finalOptionList.push(mainGuid);
                        } else {
                            $.notify(data.msg);
                        }
                    }
                });
            }
            return returnHtml;
        },

        /**
         * 操作记录弹框
         * @param obj
         * @param mainGuid
         */
        recordBox: function(obj, mainGuid) {
            var thisObj = $(obj);
            if (thisObj.hasClass('close')) {
                $("#recordBox").hide();
                $("#dialog-box-mask").remove();
            } else {
                thisContext.getManuscriptOperate(mainGuid);
                $("#recordBox").show();
                $("body").append('<div id="dialog-box-mask" style="height: 974px; display: block;"></div>');
            }
        },

        getManuscriptOperate: function(mainGuid) {
            var operateTypes = new Array();
            operateTypes.push("复制");
            operateTypes.push("签发");
            var postData = {
                mainGuid: mainGuid,
                operateTypes: JSON.stringify(operateTypes)
            }
            window.parent.cmedit.ManuscriptSystem.updatePortalStorageExpireTime();
            topUtil.ajaxRequest({
                type: "post",
                async: false,
                dataType: "json",
                url: cmedit.global.cmsPath + "ManuscriptMainController/getManuscriptOperateList",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        console.log(data);
                        var listData = {
                            list: data.data
                        }
                        if (data.data.length > 0) {
                            var appendHtml = template('operateList_html', listData);
                            $("#operateList").html(appendHtml);
                        } else {
                            $("#operateList").html('<span class="noResults">暂无记录</span>');
                        }
                    } else {
                        $.notify(data.msg);
                    }
                }
            });

        },
        /**
         * 初始化分页
         */
        initPage: function(totalPage) {
            $("#pagination").whjPaging({
                /*pageSizeOpt: [
                    {'value': 5, 'text': '5/page', 'selected': true},
                    {'value': 10, 'text': '10/page'},
                    {'value': 15, 'text': '15/page'},
                    {'value': 20, 'text': '20/page'}
                ],*/
                totalPage: totalPage,
                showPageNum: 4,
                firstPage: '<i class="iconfont icon-diyiye"></i>',
                previousPage: '<i class="iconfont icon-shangyiye"></i>',
                nextPage: '<i class="iconfont icon-xiayiye"></i>',
                lastPage: '<i class="iconfont icon-weiye"></i>',
                skip: 'skip',
                confirm: 'go',
                refresh: 'refresh',
                totalPageText: 'the total {} pages',
                isShowFL: true,
                isShowPageSizeOpt: false,
                isShowSkip: false,
                isShowRefresh: false,
                isShowTotalPage: false,
                isResetPage: true,
                callBack: function(currPage, pageSize) {
                    pageNow = currPage;
                    thisContext.initData(currPage);
                }
            });
            /*$('#pagination').whjPaging('setPage',1,totalPage);*/
        },
        /**
         * 初始化事件
         */
        initEvent: function() {

            $('.nav-link').on('click', function() {
                $('.nav-link').removeClass('nav_active');
                $(this).addClass('nav_active');
            });

            $('.container_buttons button').on('click', function() {
                $(this).addClass('active').siblings().removeClass('active');
                thisContext.initData();
            });

            $('.manu_copy').on('click', function() {
                var tipHeight = $(window).height() - $(this).offset().top;
                if (tipHeight < 232) {
                    $(this).next().removeClass('dropdown-menutop');
                    $(this).next().addClass('dropdown-menubot');
                }
            });

            /**
             * 审核意见改变时，根据审核意见隐藏或者显示指定审核人
             */
            $("input[name='censorType']").on('change', function() {
                var censorResultType = $("input[name='censorType']:checked").val();
                if (censorResultType == "3") {
                    $('.checkPeople').hide();
                } else if (censorResultType == "2" && isCheckCopy != 0) {
                    $('.checkPeople').show();
                }
            });

            $(".modalClose").on('click', function() {
                thisContext.initModel();
            });
            //时间筛选绑定change事件
            /*$('#endTime').change(function() {
            	thisContext.initData();
            });*/
            //栏目筛选功能
            /*$('#preReportColumn').change(function(){
            	thisContext.initData();
            });*/
            //刷新列表
            $('.manu_refresh').on('click', function() {
                thisContext.clearCondition();
                //thisContext.initData();
            });
            /*$('#confirmCensor').on('click',function(){
            	var son = window.top.document.getElementsByName('manuscriptIframe')[0].contentWindow;
            	son.cmedit.EditSystem.censorManuscript();
            });*/

        },
        /**
         * 清空我的稿件、全部稿件条件选择框
         */
        clearCondition: function() {
            $("#preReportColumn").val('');
            $('#searchContent').val('');
            $("#preReportColumn").selectpicker('refresh');
            $(".container_buttons button[states='']").addClass('active').siblings().removeClass('active');
            $('.date-picker input').val('').datepicker('clearDates');
        },
        /**
         * 全选
         */
        allfileSelected: function() {
            if ($('#allSelected').prop('checked')) {
                $('.select-check').prop('checked', true);
                $('.list_check').addClass('list_checked');
                $('.res-one').addClass('ulChecked');
                selectIds = [];
                for (var i = 0; i < $('#manuscripyBody .list_checked').length; i++) {
                    selectIds.push($('#manuscripyBody .listone_check').eq(i).attr('id'));
                }
            } else {
                $('.select-check').prop('checked', false);
                $('.list_check').removeClass('list_checked');
                $('.res-one').removeClass('ulChecked');
                selectIds = [];
            }
        },
        /**
         * 选择框点击事件
         */
        listOneCheckClick: function(obj, id, columnId) {
            /*setTimeout(function(){*/
            if (!$(obj).prev().prop('checked')) {
                $(obj).addClass('list_checked');
                selectIds.push(id);
                if (listTotalCount >= listPageSize) {
                    if ($('.list_checked').length >= listPageSize) {
                        $('#allSelected').prop('checked', true);
                    }
                } else {
                    if ($('#manuscripyBody .list_checked').length == listTotalCount) {
                        $('#allSelected').prop('checked', true);
                    }
                }
            } else {
                $(obj).removeClass('list_checked');
                selectIds.splice($.inArray(id, selectIds), 1);
                $('#allSelected').prop('checked', false);
                $('#allSelected').next().removeClass('list_checked');
            }
            /*},200);*/
        },

        initExternalOld: function() {
            var key = window.sessionStorage.getItem("externalKey");
            window.sessionStorage.removeItem("externalKey");
            if (cmedit.global.isNotEmpty(key)) {
                if (key.indexOf("_ONEKEY_MANUSCRIPT") != -1) {
                    var postData = {
                        key: key
                    }
                    cmedit.global.ajaxRequest({
                        type: 'POST',
                        url: cmedit.global.cmsPath + 'OneKeyManuscriptController/getExternalManuscript',
                        data: postData,
                        dataType: 'json',
                        async: true,
                        success: function(data) {
                            debugger;
                            if (data.status) {
                                if (data.data != null) {
                                    window.sessionStorage.setItem("externalManuscript", JSON.stringify(data.data.cmsManuscript));
                                    thisContext.enterDetail('new');
                                }
                            } else {
                                alert(data.msg);
                                flag = false;
                            }
                        }
                    });
                } else if (key.indexOf("__COPYMANUSCRIPT__") != -1) {
                    var mainGuid = key.split("__COPYMANUSCRIPT__")[0];
                    var mainHeader = decodeURI(key.split("__COPYMANUSCRIPT__")[1]);
                    thisContext.enterDetail(mainGuid, mainHeader);
                }
            }
        },
        initExternal: function() {
            var key = window.sessionStorage.getItem("externalKey");
            window.sessionStorage.removeItem("externalKey");
            if (cmedit.global.isNotEmpty(key)) {
                if (key.indexOf("__COPYMANUSCRIPT__") != -1) {
                    var mainGuid = key.split("__COPYMANUSCRIPT__")[0];
                    //        			var mainHeader = decodeURIComponent(key.split("__COPYMANUSCRIPT__")[1]);
                    var mainHeader = key.split("__COPYMANUSCRIPT__")[1];
                    thisContext.enterDetail(mainGuid, mainHeader);
                }
                if (key.indexOf("_ONEKEY_") != -1) {
                    var mainGuid = key.split("_ONEKEY_")[0];
                    //        			var mainHeader = decodeURIComponent(key.split("_ONEKEY_")[1]);
                    var mainHeader = key.split("_ONEKEY_")[1];
                    thisContext.enterDetail(mainGuid, mainHeader);
                }
            }
        },

        /**
         *移除页签
         */
        removeTab: function(i, flag) {
            if (!flag) {
                var oldHeadContent = window.sessionStorage.getItem(i + "_head");
                var oldTextContent = window.sessionStorage.getItem(i + "_text");
                if (cmedit.global.isNotEmpty(oldTextContent)) {
                    oldTextContent = oldTextContent.replace(/[\r\n\s]/g, "").replace(/[\r\n]/g, "").replace("<p><br/></p>", "");
                }
                var childIframe = $('#iframe_' + i)[0].contentWindow;
                var nowHeadContent = childIframe.cmedit.EditSystem.getHeadContent();
                var nowTextContent = childIframe.cmedit.EditSystem.getEditorContent();
                //当在html模式下退出稿件，文本中会在实际换行处添加换行符号
                if (cmedit.global.isNotEmpty(nowTextContent)) {
                    nowTextContent = nowTextContent.replace(/[\r\n\s]/g, "").replace(/[\r\n]/g, "").replace("<p><br/></p>", "");
                }
                window.sessionStorage.removeItem(i + "_head");
                window.sessionStorage.removeItem(i + "_text");
            }
            var delMsg = "是否保存稿件?";
            if ((oldHeadContent != nowHeadContent || oldTextContent != nowTextContent) && !flag) {
                $('#manuscriptDel').dialogBox({
                    type: 'yes/no', //three type:'normal'(default),'correct','error',
                    width: 400,
                    height: 200,
                    hasMask: true, //是否显示遮罩层
                    hasClose: true, //是否显示关闭按钮
                    hasBtn: true, //是否显示操作按钮，如取消，确定
                    autoHide: false,
                    zIndex: 99999, //弹出层定位层级
                    effect: 'fade',
                    title: ' ',
                    content: delMsg,
                    confirm: function() {
                        childIframe.cmedit.EditSystem.saveManuscript();
                        if (i == "new") { //如果是新建稿件，获取保存后的标题
                            i = tabActivelist[tabActivelist.length - 1];
                        }
                        var mainHeader = window.sessionStorage.getItem(i + "_head");
                        leftType = resourceType;
                        $('.myManulistContents').find('#tab_list').addClass('active in');
                        $('.myManulistTabs').find('#li_' + i).prev().find("a").click();
                        $('.myManulistTabs').find('#li_' + i).remove();
                        $('.myManulistContents').find('#tab_' + i).remove();
                        var lockFlag = window.sessionStorage.getItem('lock_' + i);
                        tabActivelist.splice($.inArray(i, tabActivelist), 1);
                        thisContext.resizeTab();
                        if (i != 'manuSend' && i != 'manuTask' && i != 'manuDownload' && i != 'manuSendTask' && lockFlag == 'true') {
                            thisContext.lockManuscript(i, false);
                        }
                    },
                    cancel: function() {
                        leftType = resourceType;
                        $('.myManulistContents').find('#tab_list').addClass('active in');
                        $('.myManulistTabs').find('#li_' + i).prev().find("a").click();
                        $('.myManulistTabs').find('#li_' + i).remove();
                        $('.myManulistContents').find('#tab_' + i).remove();
                        var lockFlag = window.sessionStorage.getItem('lock_' + i);
                        tabActivelist.splice($.inArray(i, tabActivelist), 1);
                        thisContext.resizeTab();
                        if (i != 'manuSend' && i != 'manuTask' && i != 'manuDownload' && i != 'manuSendTask' && lockFlag == 'true') {
                            thisContext.lockManuscript(i, false);
                            /*$('.nav-item a').removeClass('nav_active');*/
                        }
                    }
                });

            } else {
                leftType = resourceType;
                $('.myManulistContents').find('#tab_list').addClass('active in');
                $('.myManulistTabs').find('#li_' + i).prev().find("a").click();
                $('.myManulistTabs').find('#li_' + i).remove();
                $('.myManulistContents').find('#tab_' + i).remove();
                var lockFlag = window.sessionStorage.getItem('lock_' + i);
                tabActivelist.splice($.inArray(i, tabActivelist), 1);
                thisContext.resizeTab();
                if (i != 'manuSend' && i != 'manuTask' && i != 'manuDownload' && i != 'manuSendTask' && lockFlag == 'true') {
                    //解锁稿件
                    thisContext.lockManuscript(i, false);
                }
            }
        },
        /**
         * 锁定/解锁稿件
         */
        lockManuscript: function(mainGuid, lockOrUnlock) {
            var flag = false;
            var postData = {
                mainGuid: mainGuid,
                privilegeIds: "",
                lockOrUnlock: lockOrUnlock,
            };
            cmedit.global.ajaxRequest({
                type: 'POST',
                url: cmedit.global.cmsPath + 'ManuscriptMainController/lockOrUnlockManuscript',
                data: postData,
                dataType: 'json',
                async: false,
                success: function(data) {
                    if (data.status) {
                        flag = true;
                    } else {
                        alert(data.msg);
                        flag = false;
                    }
                }
            });
            return flag;
        },
        /**
         *添加页签
         */
        enterDetail: function(mainGuid, mainHeader, origin) {
            if (origin) mainHeader = decodeURIComponent(mainHeader);
            if (mainHeader == "manuscript") {
                mainHeader = decodeURI($("#" + mainGuid).attr("mainheader"));
            }
            var isTab = $.inArray(mainGuid, tabActivelist);
            if (isTab >= 0) {
                $('.myManulistTabs').find('li').removeClass('active');
                $('.myManulistContents').find('.tab-pane').removeClass('active in');
                $('.myManulistTabs').find('#li_' + mainGuid).addClass('active');
                $('.myManulistContents').find('#tab_' + mainGuid).addClass('active in');
                //如果点击左侧tab栏，刷新回收站列表数据
                if (mainGuid == 'manuRecycle') {
                    var childIframe = $('#iframe_manuRecycle')[0].contentWindow;
                    childIframe.cmedit.RecycleSystem.initData();
                }
                if (mainGuid == 'manuTask') {
                    var childIframe = $('#iframe_manuTask')[0].contentWindow;
                    childIframe.cmedit.TaskSystem.initData();
                }
                if (mainGuid == 'manuSend') {
                    var childIframe = $('#iframe_manuSend')[0].contentWindow;
                    childIframe.cmedit.TargetSystem.initData();
                }
                if (mainGuid == 'manuDownload') {
                    var childIframe = $('#iframe_manuDownload')[0].contentWindow;
                    childIframe.cmedit.DownloadSystem.initData();
                }
                if (mainGuid == 'manuSendTask') {
                    var childIframe = $('#iframe_manuSendTask')[0].contentWindow;
                    //childIframe.cmedit.TargetManager.initData();
                    childIframe.cmedit.TargetManager.initData();
                }
            } else {
                $('.myManulistTabs').find('li').removeClass('active');
                $('.myManulistContents').find('.tab-pane').removeClass('active in');
                if (mainGuid == 'new') {
                    $('.myManulistTabs').append('<li class="active" id="li_' + mainGuid + '" onclick="cmedit.ManuscriptSystem.isLeftTab(\'' + mainGuid + '\');"><a href="#tab_' + mainGuid + '" data-toggle="tab"><span>' + '新建' + '</span><i class="fa fa-times-circle" onclick="cmedit.ManuscriptSystem.removeTab(\'' + mainGuid + '\')"></i></a></li>');
                    $('.myManulistContents').append('<div class="tab-pane fade active in" id="tab_' + mainGuid + '" style="height:100%;"><iframe id="iframe_' + mainGuid + '" name="manuscriptIframe" width="100%" height="100%" src="../../views/manuscript/manuscript_edit.html" scrolling="no" frameborder="0"></iframe></div>');
                } else {
                    if (mainGuid != "manuTask" && mainGuid != "manuSend" && mainGuid != "manuDownload" && mainGuid != "manuSendTask" && mainGuid != "manuRecycle") {
                        $('.myManulistTabs').append('<li class="active" id="li_' + mainGuid + '" onclick="cmedit.ManuscriptSystem.isLeftTab(\'' + mainGuid + '\');"><a href="#tab_' + mainGuid + '" data-toggle="tab"><span title="' + mainHeader + '">' + mainHeader + '</span><i class="fa fa-times-circle" onclick="cmedit.ManuscriptSystem.removeTab(\'' + mainGuid + '\')"></i></a></li>');
                    } else {
                        $('.myManulistTabs').append('<li class="active" id="li_' + mainGuid + '" onclick="cmedit.ManuscriptSystem.isLeftTab(\'' + mainGuid + '\');"><a href="#tab_' + mainGuid + '" data-toggle="tab"><span title="' + mainHeader + '">' + mainHeader + '</span><i class="fa fa-times-circle" onclick="cmedit.ManuscriptSystem.removeTab(\'' + mainGuid + '\',true)"></i></a></li>');
                    }
                    if (mainGuid == 'manuTask') {
                        $('.myManulistContents').append('<div class="tab-pane fade active in" id="tab_' + mainGuid + '" style="height:100%;"><iframe id="iframe_' + mainGuid + '" width="100%" height="100%" src="../../views/manuscript/manuscript_task.html" scrolling="auto" frameborder="0"></iframe></div>');
                    } else if (mainGuid == 'manuSend') {
                        $('.myManulistContents').append('<div class="tab-pane fade active in" id="tab_' + mainGuid + '" style="height:100%;"><iframe id="iframe_' + mainGuid + '" width="100%" height="100%" src="../../views/manuscript/manuscript_send.html" scrolling="auto" frameborder="0"></iframe></div>');
                    } else if (mainGuid == 'manuDownload') {
                        $('.myManulistContents').append('<div class="tab-pane fade active in" id="tab_' + mainGuid + '" style="height:100%;"><iframe id="iframe_' + mainGuid + '" width="100%" height="100%" src="../../views/manuscript/manuscript_download.html" scrolling="auto" frameborder="0"></iframe></div>');
                    } else if (mainGuid == 'manuSendTask') {
                        $('.myManulistContents').append('<div class="tab-pane fade active in" id="tab_' + mainGuid + '" style="height:100%;"><iframe id="iframe_' + mainGuid + '" width="100%" height="100%" src="../../views/manuscript/manuscript_sendtask.html" scrolling="auto" frameborder="0"></iframe></div>');
                    } else if (mainGuid == 'manuRecycle') {
                        $('.myManulistContents').append('<div class="tab-pane fade active in" id="tab_' + mainGuid + '" style="height:100%;"><iframe id="iframe_' + mainGuid + '" width="100%" height="100%" src="../../views/manuscript/manuscript_recycle.html" scrolling="auto" frameborder="0"></iframe></div>');
                    } else {
                        $('.myManulistContents').append('<div class="tab-pane fade active in" id="tab_' + mainGuid + '" style="height:100%;"><iframe id="iframe_' + mainGuid + '" name="manuscriptIframe" width="100%" height="100%" src="../../views/manuscript/manuscript_edit.html?mainGuid=' + mainGuid + '" scrolling="no" frameborder="0"></iframe></div>');
                    }
                }
                tabActivelist.push(mainGuid);
                thisContext.resizeTab();
            }
        },
        /**
         *预览窗口
         */
        enterPreview: function(obj, mainGuid) {
            var thisObj = $(obj);
            $('#manuscript_preview').show();
            window.top.$('body').append('<div id="box_mask" class="dialog-box-mask"></div>');
            $('#manuscript_preview').append('<iframe width="100%" height="100%" src="../../views/manuscript/manuscript_preview.html?mainGuid=' + mainGuid +
                '&tenantId=' + tenantId +
                '" frameborder="0" scrolling="no" id="previewIframe"></iframe>');
            $('#close').on('click', function() {
                $('#manuscript_preview').hide();
                $('#previewIframe').remove();
                $('#box_mask').remove();
            });

        },
        /**
         * 重置tab宽度
         */
        resizeTab: function() {
            var addTabnums = $(".myManulistTabs li").length;
            var maxWidth = ($('.myManulistTabs').width() - 100) / addTabnums - 52;
            console.log(maxWidth);
            $('.myManulistTabs li span').css('maxWidth', maxWidth);
        },
        /**
         *滚动条样式
         */
        scrollType: function(scrollId, scrollHeight) {
            $(scrollId).slimScroll({
                height: scrollHeight, //可滚动区域高度
                size: '5px', //组件宽度
                color: '#999', //滚动条颜色
                railOpacity: .3, //滚动条透明度
                disableFadeOut: true, //鼠标经过可滚动区域时显示组件，离开时隐藏组件
                wheelStep: 20, //滚轮滚动量
                alwaysVisible: true, //始终显示组件
                borderRadius: '7px' //滚动条圆角
            });
        },
        /**
         *列表状态显示
         */
        istatusMouseover: function(e) {
            var tipHeight = $(window).height() - $(e).offset().top;
            console.log(tipHeight);
            if (tipHeight < 122) {
                $(e).next().removeClass('dropdown_tiptop');
                $(e).next().addClass('dropdown_tipbot');
            }
            /*manuscriptSystem.isHeight();*/
            $(e).next().show();
        },
        istatusMouseout: function(e) {
            $(e).next().hide();
        },


        /**
         * 审核稿件
         */
        censorManuscript: function() {
            var censorResultType = $("input[name='censorType']:checked").val();
            var censorOpinion = $("#auditComments").val();
            var mainGuid = $("#censorMainGuid").val();
            var fromTask = $("#fromTask").val(); // 审核来源（审核列表【manuTask】点开和编辑页面点开）
            var cstIsStepback = $("#isStepback").val();
            var nominatorId = $("#nextCensor").val();
            var nominator = $("#nextCensor").find("option:selected").text();
            var casData = JSON.parse(window.localStorage.getItem("login_casData"));
            var postData = {
                mainGuid: mainGuid,
                censorResultType: censorResultType,
                censorOpinion: censorOpinion,
                nominatorId: nominatorId,
                nominator: nominator,
                orgCode: casData.orgCode,
                cstIsStepback : cstIsStepback
            }
            topUtil.ajaxRequest({
                type: "post",
                async: false,
                dataType: "json",
                url: cmedit.global.cmsPath + "CmsController/auditManuscript",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        thisContext.initData();
                        thisContext.initModel();
                        if ("manuTask" == fromTask) {
                            var childIframe = $('#iframe_manuTask')[0].contentWindow;
                            childIframe.cmedit.TaskSystem.initData();
                        } else {
                            thisContext.removeTab(mainGuid, true);

                        }

                    } else {
                        console.log(data);
                    }
                }
            });

        },
        
        /**
         * 单条删除
         */
        delResoureSingle:function(mainGuid,userId,mainStatus){
        	var selectIds = [];
            var mainObj = {};
            mainObj.mainGuid = mainGuid;
            mainObj.mainCreateUserId = userId;
            mainObj.mainStatus = mainStatus;
            selectIds.push(mainObj);
            thisContext.delResoure(selectIds);
        },
        
        /**
         * 批量删除
         */
        selectDelect: function() {
            var choosenList = $('#manulistTable').bootstrapTable('getSelections');
            if (choosenList.length == 0) {
                $.notify("请先选择记录！");
                $('.manuLoader').hide();
                return false;
            } else {
                var selectIds = [];
                for (var i = 0; i < choosenList.length; i++) {
                	var mainObj = {};
                	mainObj.mainGuid = choosenList[i].mainGuid;
                	mainObj.mainCreateUserId = choosenList[i].mainCreateUserId;
                	mainObj.mainStatus = choosenList[i].mainStatus;
                    selectIds.push(mainObj);
                }
                thisContext.delResoure(selectIds);
            }

        },
        /**
         * 删除操作
         */
        delResoure: function(mainGuidObj, fromIframe) {
            var activeNum = 0;
            var activeList = [];
            var delFlag = true;
            var mainGuidlist = [];
            var delMsg = "";
            for (var i = 0; i < mainGuidObj.length; i++) {
            	if (mainGuidObj[i].mainCreateUserId == window.sessionStorage.getItem("userId") && 
            			privilegeIds.indexOf(cmedit.global.privilegeWritescripts) > -1 && 
            			(mainGuidObj[i].mainStatus == "0" || mainGuidObj[i].mainStatus =="3")) {
            		mainGuidlist.push(mainGuidObj[i].mainGuid);
            	}else if(mainGuidObj[i].mainStatus == "2" && privilegeIds.indexOf(cmedit.global.privilegeDelFinishscripts) != -1){
            		mainGuidlist.push(mainGuidObj[i].mainGuid);
            	}else if(privilegeIds.indexOf(cmedit.global.privilegeDelallscripts) != -1 &&
            			privilegeIds.indexOf(cmedit.global.privilegeDelFinishscripts) == -1){
            		mainGuidlist.push(mainGuidObj[i].mainGuid);
            	}else {
            		delFlag = false;
            		break;
            	}
            }
            
            /*console.log(flag);*/
            if (delFlag) {
                //判断要删除的稿件是否有已锁定的
                for (var i = 0; i < mainGuidlist.length; i++) {
                    var lockFlag = thisContext.manuscriptIsLocked(mainGuidlist[i]);
                    if (!lockFlag) {
                        var mainHeader = $("#" + mainGuidlist[i]).attr("mainHeader");
                        $.notify("《" + decodeURI(mainHeader) + "》已被锁定，不能删除");
                        return false;
                    }
                }
                //判断要删除的稿件中是否是已经打开的
                for (var i = 0; i < mainGuidlist.length; i++) {
                    for (var j = 0; j < tabActivelist.length; j++) {
                        if (mainGuidlist[i] == tabActivelist[j]) {
                            activeList.push(mainGuidlist[i]);
                            activeNum++;
                            break;
                        }
                    }
                }
                if (activeNum > 0) {
                    delMsg = "有" + activeNum + "篇稿件正在编辑，确定要删除吗？";
                } else {
                    delMsg = "确定要删除该稿件吗?";
                }
                $('#manuscriptDel').dialogBox({
                    type: 'correct', //three type:'normal'(default),'correct','error',
                    width: 400,
                    height: 200,
                    hasMask: true, //是否显示遮罩层
                    hasClose: true, //是否显示关闭按钮
                    hasBtn: true, //是否显示操作按钮，如取消，确定
                    autoHide: false,
                    zIndex: 99999, //弹出层定位层级
                    effect: 'fade',
                    title: ' ',
                    content: delMsg,
                    confirm: function() {
                        var data = {
                            "mainGuid": JSON.stringify(mainGuidlist)
                        }
                        topUtil.ajaxRequest({
                            type: "post",
                            async: true,
                            dataType: "json",
                            url: cmedit.global.cmsPath + "ManuscriptMainController/deleteManuscript",
                            data: data,
                            success: function(data) {
                                if (data.status) {
                                    var tabDelect = [];
                                    for (var a = 0; a < activeList.length; a++) {
                                        thisContext.removeTab(activeList[a], true);
                                    }
                                    $.notify("稿件删除成功");
                                    // childIframe.cmedit.TargetSystem.initData();
                                    // 刷新列表
                                    if ("manuTask" == fromIframe) {
                                        var childIframe = $('#iframe_manuTask')[0].contentWindow;
                                        childIframe.cmedit.TaskSystem.initData();
                                    } else if ("manuSendTask" == fromIframe) {
                                        var childIframe = $('#iframe_manuSendTask')[0].contentWindow;
                                        childIframe.cmedit.TargetManager.initData();
                                    } else {
                                        thisContext.initData();
                                    }
                                    console.log(tabActivelist);
                                } else {
                                    $.notify(data.msg);
                                }
                            }
                        });
                    }
                });
            } else {
                $.notify("不能删除该稿件");
            }

        },
        /**
         * 撤回操作
         */
        recallResoure: function(mainGuid,sendmanuscriptTargetGuid,myGuid,fromIframe) {
            var activeNum = 0;
            var activeList = [];
            var recallFlag = true;
            // var mainGuidlist = [];
            var recallMsg = "";
            var status = $("#" + mainGuid).attr("status");
                //如果改用户拥有撤回稿件权利，则直接撤回，否则进行撤回自己稿件逻辑判断
//                if (privilegeIds.indexOf(cmedit.global.privilegeDelallscripts) == -1) {
//                    //该用户拥有创建稿件的权利，那么可以撤回自己创建的，并且状态是待提交或者已打回的稿件
//                    if (privilegeIds.indexOf(cmedit.global.privilegeWritescripts) > -1) {
//                        if ($("#" + mainGuid).attr("status") == "1" || $("#" + mainGuid).attr("status") == "2") {
//                            recallFlag = false;
//                        }
//                        if ($("#" + mainGuid).attr("name") != window.sessionStorage.getItem("userId")) {
//                            recallFlag = false;
//                        }
//                    } else {
//                        recallFlag = false;
//                    }
//                }
                if ($("#" + mainGuid).attr("name") == window.sessionStorage.getItem("userId") && 
            			privilegeIds.indexOf(cmedit.global.privilegeWritescripts) > -1 && 
            			(status == "0" || status =="3")) {
                	recallFlag = true;
            	}else if(status == "2" && privilegeIds.indexOf(cmedit.global.privilegeDelFinishscripts) != -1){
            		recallFlag = true;
            	}else if(privilegeIds.indexOf(cmedit.global.privilegeDelallscripts) != -1 &&
            			privilegeIds.indexOf(cmedit.global.privilegeDelFinishscripts) == -1){
            		recallFlag = true;
            	}else {
            		recallFlag = false;
            	}
                // mainGuidlist.push(mainGuid);
                var forenoonStr = "";
                for (let timeStr in sendmanuscriptTargetGuid) {
                    forenoonStr += '<span>' + sendmanuscriptTargetGuid[timeStr] + '</span>';
                    };
                // document.getElementById("channelPlace").innerHTML = forenoonStr;
            /*console.log(flag);*/
            if (recallFlag) {
                //判断要撤回的稿件是否有已锁定的
                // for (var i = 0; i < mainGuidlist.length; i++) {
                //     var lockFlag = thisContext.manuscriptIsLocked(mainGuidlist[i]);
                //     if (!lockFlag) {
                //         var mainHeader = $("#" + mainGuidlist[i]).attr("mainHeader");
                //         $.notify("《" + mainHeader + "》已被锁定，不能撤回");
                //         return false;
                //     }
                // }
                //判断要撤回的稿件中是否是已经打开的
                // for (var i = 0; i < mainGuidlist.length; i++) {
                //     for (var j = 0; j < tabActivelist.length; j++) {
                //         if (mainGuidlist[i] == tabActivelist[j]) {
                //             activeList.push(mainGuidlist[i]);
                //             activeNum++;
                //             break;
                //         }
                //     }
                // }
                // if (activeNum > 0) {
                //     recallMsg = "有" + activeNum + "篇稿件正在编辑，确定要撤回吗？";
                // } else {
                //     recallMsg = "确定要撤回该稿件吗"; 
                // }
                var content = '<p style="font-size:14px;text-align:left;">确定对已签发渠道进行撤回吗？</p><p style="font-size:14px;color:#e2e2e2;text-align:left;line-height: 30px;">撤回渠道:</p><div style="width:100%;height:40px;font-size: 14px;color: #151515;text-align:left;" id="channelPlace">'+forenoonStr+'</div>';
                $('#manuscriptRecall').dialogBox({
                    type: 'correct', //three type:'normal'(default),'correct','error',
                    width: 360,
                    height: 260,
                    title: '<p style="padding-top:14px;font-family: PingFangSC-Regular; font-size: 16px; color: #333333;">撤回</p>',
                    hasMask: true, //是否显示遮罩层
                    hasClose: true, //是否显示关闭按钮
                    hasBtn: true, //是否显示操作按钮，如取消，确定
                    autoHide: false,
                    zIndex: 99999, //弹出层定位层级
                    effect: 'fade',
                    content: content,
                    confirm: function() {
                        var paramDatas = {
                          
                        }
                        paramDatas.manuscriptNewTargetList=myGuid
                        console.log(paramDatas)
                        topUtil.ajaxRequest({
                            type: "post",
                            async: true,
                            dataType: "json",
                            contentType: "application/json;charset=UTF-8",
                            url: cmedit.global.cmsPath + "CmsNewTargetController/distributeRevoke",    
                            data:  JSON.stringify(paramDatas),
                            success: function(data) {
                                if (data.status) {
                                    // var tabDelect = [];
                                    // for (var a = 0; a < activeList.length; a++) {
                                    //     thisContext.removeTab(activeList[a], true);
                                    // }
                                    $.notify("稿件撤回成功");
                                    // 刷新列表
                                    if ("manuSend" == fromIframe) {
                                        var childIframe = $('#iframe_manuSend')[0].contentWindow;
                                        childIframe.cmedit.TargetSystem.initData();
                                    } else {
                                        thisContext.initData();
                                    }
                                } else {
                                    $.notify(data.msg);
                                }
                            }
                        });
                        thisContext.initData()
                    }
                });
            } else {
                $.notify("不能撤回该稿件");
            }
            this.initdialogBox();
        },
        // 初始化对话框
        initdialogBox:function(){
            var len = 92;      //默认显示字数
            var ctn = document.getElementById("channelPlace");  //获取div对象
            var content = ctn.innerHTML;                   //获取div里的内容
            // alert(content);
            var span = document.createElement("span");     //创建<span>元素
            var a = document.createElement("a");           //创建<a>元素
            span.innerHTML = content.substring(0,len);     //span里的内容为content的前len个字符
            a.innerHTML = content.length>len?"展开&nbsp;<i class='iconfont icon-xiala2' font-size='12px' />":"";      
            a.href = "javascript:void(0)";//让a链接点击不跳转
            a.onclick = function(){
                  span.innerHTML = content;
                  a.innerHTML=""
            };
            // 设置div内容为空，span元素 a元素加入到div中
            ctn.innerHTML = "";
            ctn.appendChild(span);
            ctn.appendChild(a);
        },
        /**
         * 判断稿件是否锁定
         */
        manuscriptIsLocked: function(manuscriptId) {
            var lockFlag = false;
            var postData = {
                mainGuid: manuscriptId
            }
            topUtil.ajaxRequest({
                type: "post",
                async: false,
                dataType: "json",
                url: cmedit.global.cmsPath + "ManuscriptMainController/manuscriptIsLocked",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        lockFlag = true;
                    } else {
                        lockFlag = false;
                    }
                }
            });
            return lockFlag;
        },
        confirmLocalization: function(callFunc) {
            $('#isLocalizationImg').dialogBox({
                type: 'correct', //three type:'normal'(default),'correct','error',
                width: 400,
                height: 200,
                hasMask: true, //是否显示遮罩层
                hasClose: true, //是否显示关闭按钮
                hasBtn: true, //是否显示操作按钮，如取消，确定
                autoHide: false,
                zIndex: 99999, //弹出层定位层级
                effect: 'fade',
                title: ' ',
                content: "存在外部资源，确认继续签发吗？",
                confirm: function() {
                    callFunc();
                },
                cancel: function() {}
            });
        },
        /**
         * 删除签发记录
         * @param mntGuid
         */
        deleteDistribute: function(mntGuid) {
            $('#sendDel').dialogBox({
                type: 'correct', //three type:'normal'(default),'correct','error',
                width: 400,
                height: 200,
                hasMask: true, //是否显示遮罩层
                hasClose: true, //是否显示关闭按钮
                hasBtn: true, //是否显示操作按钮，如取消，确定
                autoHide: false,
                zIndex: 99999, //弹出层定位层级
                effect: 'fade',
                title: ' ',
                content: '是否删除签发记录？',
                confirm: function() {
                    var postData = {
                        "mntGuid": mntGuid,
                    }
                    topUtil.ajaxRequest({
                        type: "post",
                        async: true,
                        dataType: "json",
                        url: cmedit.global.cmsPath + "CmsNewTargetController/deleteDistribute",
                        data: postData,
                        success: function(data) {
                            if (data.status) {
                                $.notify("签发记录删除成功");
                                var iframe_manuSend = window.top.document.getElementById('iframe_manuSend').contentWindow;
                                iframe_manuSend.cmedit.TargetSystem.init();
                            } else {
                                $.notify(data.msg);
                            }
                        }
                    });
                }
            });
            /*topUtil.alert(function(flag){
        		if(flag){
        			var postData = {
                    		"mntGuid" : mntGuid,
                    	}
                    	topUtil.ajaxRequest({
            				type: "post",
            				async: true,
            				dataType: "json",
            				url: cmedit.global.releasePath+"ManuscriptNewTargetController/deleteDistribute",
            				data: postData,
            				success: function(data){
            					if(data.status) {
            						alert("签发记录删除成功");
            						thisContext.init();
            					}else{
            						alert("签发记录删除失败");
            					}
            				}
            			});
        		}
        	},"是否删除签发记录")*/

        },
        /**
         * 左侧tab切换
         */
        initTableft: function(e) {
            //取消自动保存定时器
            thisContext.clearAutoMenu();
            $('#allSelected').prop('checked', false);
            $('.select-check').prop('checked', false);
            $('.list_check').removeClass('list_checked');
            $('.res-one').removeClass('ulChecked');
            $('#li_list').siblings().removeClass('active');
            $('#tab_list').siblings().removeClass('active in');
            selectIds = [];
            resourceType = $(e).attr('name');
            if (resourceType == 1) {
                $('#li_list').removeClass('allManulist');
                $('#li_list').addClass('active myManulist');
                $('#tab_list').addClass('active in');
                $('.onlyTab').html('我的稿件');
                thisContext.clearCondition();
                thisContext.initData();
            } else if (resourceType == 2) {
                $('#li_list').removeClass('myManulist');
                $('#li_list').addClass('active allManulist');
                $('#tab_list').addClass('active in');
                $('.onlyTab').html('部门稿件');
                thisContext.clearCondition();
                thisContext.initData();
            } else if (resourceType == 3) {
                thisContext.enterDetail('manuTask', '审核任务');
            } else if (resourceType == 4) {
                thisContext.enterDetail('manuSend', '签发监控');
            } else if (resourceType == 5) {
                thisContext.enterDetail('manuDownload', '下载监控');
            } else if (resourceType == 6) {
                thisContext.enterDetail('manuSendTask', '成品稿库');
            } else if (resourceType == 7) {
                thisContext.enterDetail('manuRecycle', '回收站');
            }
        },

        /**
         * 初始化栏目
         */
        initColumn: function() {
            //判断该成员是否属于大采访部，如果是，则可以显示所有的栏目
            if (userColumnIds.indexOf(bigColumnId) > 0) {
                for (var i = 0; i < allColumnInfo.length; i++) {
                    $("#preReportColumn").append('<option value="' + allColumnInfo[i].id + '">' + allColumnInfo[i].name + '</option>');
                }
            } else {
                for (var i = 0; i < columnInfo.length; i++) {
                    $("#preReportColumn").append('<option value="' + columnInfo[i].id + '">' + columnInfo[i].name + '</option>');
                }
            }
            $("#preReportColumn").selectpicker('refresh');
        },
        submitManuscriptMode:function(postData){
        	topUtil.ajaxRequest({
        		type: "post",
        		async: false,
        		dataType: "json",
        		url: cmedit.global.cmsPath + "CmsController/submitManuscript",
        		data: postData,
        		success: function(data) {
        			if (data.status) {
        				thisContext.initData();
        				$.notify("提交成功");
        				//提交稿件后关闭当前页签
        				thisContext.removeTab($("#submitMainGuid").val());
//                    location.replace(location);
        			} else {
        				$.notify(data.msg);
        			}
        		}
        	});
        },
        /**
         * 提交稿件
         */
        submitManuscript: function() {
            var submitGuid = $("#submitMainGuid").val();
            var editTitle = $("#editTitle").val();
            var targetSystemIds = [];
            var targetSystemNames = [];
            var casData = JSON.parse(window.localStorage.getItem("login_casData"));
            $.each($("input[name='targetRadio']:checked"), function() {
                targetSystemIds.push($(this).val());;
            });
            var postData = {
                targetSystemIds: JSON.stringify(targetSystemIds),
                mainGuid: submitGuid,
                orgCode: casData.orgCode
            }
            if($("#censorPerson").is(':visible')){
                var censorAuditorId = $("#censorPerson").val();
                var censorAuditor = $("#censorPerson").find("option:selected").text();
            	postData.censorAuditorId = censorAuditorId;
            	postData.censorAuditor = censorAuditor;
            }
            var distributeFlag = window.parent.sessionStorage.getItem("distributeFlag");
            var channelNames = [];
            if(distributeFlag == '3'){
              	if($("#selectedSendTargetUl").is(':visible')){
            		var sendTargetids = [];
            		$.each($("#selectedSendTargetUl").find("input[name='issuedTarget']:checked"), function () {
            			sendTargetids.push({
            				"channelId": $(this).attr('channelId'),
            				"channelName": $(this).attr('channelName'),
            				"channelType": $(this).attr('channelType'),
            				"distrColumn": $(this).attr('distrColumn'),
            				"distrColumnName": $(this).attr('distrColumnName'),
                    "distrMould": isMoudId
            			});;
            			var columns = window.sessionStorage.getItem("NewsEditingSuite-platform-column-"+$(this).attr('channelId'));
            			if(cmedit.global.isNotEmpty(columns) && !$(this).attr('distrColumn')){
            				channelNames.push($(this).attr('channelName'));
            			}
            		});
            		postData.channelList = JSON.stringify(sendTargetids);
            	}
                if($("#censorPerson_sendTaskModal3").is(':visible')){
                    var censorAuditorId_sendTaskModal3 = $("#censorPerson_sendTaskModal3").val();
                    var censorAuditor_sendTaskModal3 = $("#censorPerson_sendTaskModal3").find("option:selected").text();
                	postData.censorAuditorId = censorAuditorId_sendTaskModal3;
                	postData.censorAuditor = censorAuditor_sendTaskModal3;
                }
//            	$.each($("input[name='targetRadio']:checked"), function () {
//            		targetSystemNames.push($(this).attr('channelName'));;
//                });
            	postData.distributeFlag = '3';
//            	postData.targetSystemNames = JSON.stringify(targetSystemNames);
            }
            //存在渠道有栏目但是未勾选的情况
            if(cmedit.global.isNotEmpty(channelNames)){
	            $('#distributeBtn').dialogBox({
	                type: 'correct', //three type:'normal'(default),'correct','error',
	                width: 400,
	                height: 200,
	                hasMask: true, //是否显示遮罩层
	                hasClose: true, //是否显示关闭按钮
	                hasBtn: true, //是否显示操作按钮，如取消，确定
	                autoHide: false,
	                zIndex: 99999, //弹出层定位层级
	                effect: 'fade',
	                title: ' ',
	                content: '<span style="color:red">"'+channelNames+'</span>"未选择栏目是否继续签发',
	                confirm: function () {
	                	thisContext.submitManuscriptMode(postData);
	                },
		            cancel:function(){
		            	thisContext.sendTaskModal3Show('iframe_manuSendTask');
	                }
	            });
            }else{
            	thisContext.submitManuscriptMode(postData);
            }
        },

        /**
         * 签发确定更改签发记录
         */
        determineTarget: function(paraObj) {
            console.log("determineTarget", paraObj);
            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "CmsNewTargetController/determineTarget",
                data: paraObj,
                success: function(data) {}
            });
        },

        /**
         * 构造分发表单提交
         */
        formSubmit: function(url, arg) {
            //存储签发记录id
            var taskIdArry = [];
            arg["taskList"].forEach(function(e) {
                taskIdArry.push(e.id);
            });
            window.sessionStorage.setItem("taskIdArry", JSON.stringify(taskIdArry));

            $('#manuscript_bulkIssue').show();
            window.top.$('body').append('<div id="box_mask" class="dialog-box-mask"></div>');
            $('#manuscript_bulkIssue').append('<iframe width="100%" style="background-color:#fff!important" height="100%" frameborder="0"  id="bulkIssueIframe" name="bulkIssueIframe"></iframe>');
            $('#closeIssue').on('click', function() {
                $('#manuscript_bulkIssue').hide();
                $('#bulkIssueIframe').remove();
                $('#box_mask').remove();
            });
            var form = $("<form method='post'></form>");
            form.attr("action", url);
            form.attr("target", "bulkIssueIframe");
            var input = $("<input type='hidden'>");
            input.attr("name", "param");
            input.val(JSON.stringify(arg));
            form.append(input);
            form.appendTo(document.body);
            //            form.appendTo($('#bulkIssueIframe'));
            form.submit();
        },

        /**
         * 获取稿件签发目标
         */
        getTargetList: function(mainColumnId) {
            //显示分发目标
            $("#signLabelId").show();
            var submitMainGuid = $("#submitMainGuid").val();
            var postData = {
                mainGuid: submitMainGuid,
                columnId: mainColumnId,
            }
            window.parent.cmedit.ManuscriptSystem.updatePortalStorageExpireTime();
            topUtil.ajaxRequest({
                type: "post",
                async: false,
                dataType: "json",
                url: cmedit.global.cmsPath + "CmsController/getCmsTargetSystem",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        var html = '';
                        var creTargetList = data.data.creTargetList;
                        var cmsTargetList = data.data.cmsTargetList;
                        if (creTargetList.length > 0) {
                            for (var i = 0; i < creTargetList.length; i++) {
                                html += '<label class="mt-checkbox mt-checkbox-outline">' +
                                    '<input type="checkbox" name="targetRadio" value="' + creTargetList[i].creTargetGuid + '"> ' + creTargetList[i].creTargetName + '' +
                                    '<span></span>' +
                                    '</label>';
                            }
                        }
                        if (cmsTargetList.length > 0) {
                            for (var i = 0; i < cmsTargetList.length; i++) {
                                html += '<label class="mt-checkbox mt-checkbox-outline">' +
                                    '<input type="checkbox" name="targetRadio" value="' + cmsTargetList[i].cmsTargetGuid + '"> ' + cmsTargetList[i].cmsTargetName + '' +
                                    '<span></span>' +
                                    '</label>';
                            }
                        }
                        if (html == '') {
                            html += "无签发目标";
                        }
                        $("#mainTargetList").html(html);
                        var columnCount = creTargetList.length + cmsTargetList.length;
                        if (columnCount > 0) {
                            $("input[name='targetRadio']").on('change', function() {
                                var i = $("input[name='targetRadio']:checked").length;
                                if (i > 0) {
                                    $("#confirmSubmit").attr("disabled", false);
                                } else {
                                    $("#confirmSubmit").attr("disabled", true);
                                }
                            });
                        } else {
                            $("#confirmSubmit").attr("disabled", true);
                            $.notify("请先配置签发目标!");
                            return;
                        }
                        var son = window.top.document.getElementById('iframe_' + submitMainGuid).contentWindow;
                        son.cmedit.EditSystem.initCensorPerson(mainColumnId, submitMainGuid);
                        son.cmedit.EditSystem.submitModel(columnCount, submitMainGuid);
                    } else {
                        console.log(data)
                    }
                }
            });
        },
        /**
         * 获取分发平台发分发渠道
         */
        getPlatformTargetList : function(mainColumnId,mainGuid) {
        	if(thisContext.getAsyncCreTarget()){
        		$.notify("请先同步签发目标");
        		return;
        	}
        	
            var columnIds = [];
            var mainGuids = [];
            var targetArr;
            mainGuids.push(mainGuid);
            columnIds.push(mainColumnId);
            var postData = {
                columnIds: JSON.stringify(columnIds),
                mainGuids: JSON.stringify(mainGuids),
            }
            //获取公共的签发目标
            topUtil.ajaxRequest({
                type: "post",
                async: false,
                dataType: "json",
                url: cmedit.global.cmsPath + "CmsController/getCmsTargetSystemArr",
                data: postData,
                success: function (data) {
                    if (data.status) {
                    	targetArr = data.data.creTargetList;
                    }
                }
            });
            console.log("公共的签发目标",targetArr);
            
        	//显示分发目标
            $("#signLabelId").show();
            var submitMainGuid = $("#submitMainGuid").val();
            topUtil.ajaxRequest({
                type: "get",
                async: false,
                dataType: "json",
                url : cmedit.global.cmsPath + 'CreDistributeController/getChannels',
                data: {
                    channelType: "1,2"
                },
                success: function (data) {
                    if (data.status) {
                        var channelList = data.data.channelList;
                        var channelArry = [];
                        channelList.forEach(function(channel){
                        	targetArr.forEach(function(target){
                        		var channelId = target.creServiceName.replace("CMS_","");
                        		if(channel.channelId == channelId){
                        			channelArry.push(channel);
                        		}
                        	});
                        })
                        console.log("实际签发目标",channelArry);
                        
                        var html = '';
                        if (channelArry.length > 0) {
                            for (var i = 0; i < channelArry.length; i++) {
                                html += '<label class="mt-checkbox mt-checkbox-outline">' +
                                    '<input type="checkbox" name="targetRadio" channelName="' + channelArry[i].channelName + '" value="' + channelArry[i].channelId + '"> ' + channelArry[i].channelName + '' +
                                    '<span></span>' +
                                    '</label>';
                            }
                        } else {
                            html += "无签发目标";
                        }
                        $("#mainTargetList").html(html);
                        if (channelArry.length > 0) {
                            $("input[name='targetRadio']").on('change', function () {
                                var i = $("input[name='targetRadio']:checked").length;
                                if (i > 0) {
                                    $("#confirmSubmit").attr("disabled", false);
                                } else {
                                    $("#confirmSubmit").attr("disabled", true);
                                }
                            });
                        } else {
                            $("#confirmSubmit").attr("disabled", true);
                            $.notify("请先配置签发目标!");
                            return;
                        }
                        var columnCount = channelArry.length;
                        var son = window.top.document.getElementById('iframe_' + submitMainGuid).contentWindow;
                        son.cmedit.EditSystem.initCensorPerson(mainColumnId, submitMainGuid);
                        son.cmedit.EditSystem.submitModel(columnCount, submitMainGuid);
                    } else {
                    	$.notify(data.msg);
                    }
                }
            });
        },
        /**
         * 清空审核、提交模态框
         */
        clearTaskmodal: function() {
            $("#mainTargetList").html('');
            $("#signLabelId").hide();
        },

        /**
         * 打开审核、提交模态框
         */
        taskmodalShow: function(isCheck, isSubmit) {
            isCheckCopy = isCheck;
            if (isCheck == 0) {
                $('#taskmodalDefault .checkPeople').hide();
                $('#submitModal .checkPeople').hide();
                $('#taskmodalDefault .modal-body').addClass('noCheck');
                $('#submitModal .modal-body').addClass('noCheck');
            } else {

                if ($('#taskmodalDefault .modal-body').hasClass('noCheck')) {
                    $('#taskmodalDefault .modal-body').removeClass('noCheck');
                }
                if ($('#submitModal .modal-body').hasClass('noCheck')) {
                    $('#submitModal .modal-body').removeClass('noCheck');
                }
                if (privilegeIds.indexOf(cmedit.global.privilegeDistribute) >= 0) {
                    $('#taskmodalDefault .checkDistribute').show();
                    $('#submitModal .checkDistribute').show();
                } else {
                    $('#taskmodalDefault .checkDistribute').hide();
                    $('#submitModal .checkDistribute').hide();
                }
            }
            if (isSubmit) {
                $('#submitModal').modal('show');
            } else {
                var censorResultType = $("input[name='censorType']:checked").val();
                if (censorResultType == "3") {
                    $('#taskmodalDefault .checkPeople').hide();
                    $('#submitModal .checkPeople').hide();
                } else if (censorResultType == "2" && isCheck != 0) {
                    $('#taskmodalDefault .checkPeople').show();
                    $('#submitModal .checkPeople').show();
                }
                var mainGuid = $("#censorMainGuid").val();
                thisContext.initNewTarget(mainGuid);
            }
            
            if(isCheck == 1 && isSubmit){
            	var operateType = $("#submitModal").attr("operateType");
            	if(operateType == 'submit'){
            		$("#censorPerson").on('change', function () {
  		              var censorPerson = $("#censorPerson").val();
  		              if (topUtil.isNotEmpty(censorPerson)) {
  		                  $("#confirmSubmit").attr("disabled", false);
  		              } else {
  		                  $("#confirmSubmit").attr("disabled", true);
  		              }
            		});
            	}
            	if(operateType == 'sign'){
            		$("#censorPerson").on('change', function () {
                        var censorPerson = $("#censorPerson").val();
                        var i = $("input[name='targetRadio']:checked", parent.document).length;
                        if (topUtil.isNotEmpty(censorPerson) && i > 0) {
                            $("#confirmSubmit").attr("disabled", false);
                        } else {
                            $("#confirmSubmit").attr("disabled", true);
                        }
                    });
            		$("input[name='targetRadio']").on('change', function () {
                        var i = $("input[name='targetRadio']:checked").length;
                        var censorPerson = $("#censorPerson").val();
                        if (topUtil.isNotEmpty(censorPerson) && i > 0) {
                            $("#confirmSubmit").attr("disabled", false);
                        } else {
                            $("#confirmSubmit").attr("disabled", true);
                        }
                    });
            	}
            }
        },

        /**
         * 查询稿件已经存在的签发目标
         */
        initNewTarget: function(mainGuid) {
            var postData = {
                mainGuid: mainGuid,
                mbtStatus: 1,
            }
            window.parent.cmedit.ManuscriptSystem.updatePortalStorageExpireTime();
            topUtil.ajaxRequest({
                type: "post",
                async: false,
                dataType: "json",
                url: cmedit.global.cmsPath + "NewTargetController/getManuscriptNewTargetByPage",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        var newTargetList = data.data.list;
                        var appendHtml = '';
                        if (newTargetList.length > 0) {
                            $('#newTargetList', parent.document).html('');
                            for (var i = 0; i < newTargetList.length; i++) {
                            	var html = '<span class="sendGoal">' + newTargetList[i].manuscriptTargetName + '</span>'+
                            	'<div style="position: relative;display: inline-block"><i class="popoverimg iconfont icon-tixing" style="font-size: 13px;color: #8C8C8C;" onmouseover="cmedit.ManuscriptSystem.showColumn(this,\'' + newTargetList[i].mainStrReserve2 + '\')"></i>' +
                            	'<div class="popover-box" style="left:-125px;width: 250px"><div class="popover-arrow-up" style="left:50%"></div><div class="popover_content"></div></div></div><br/>';
                            	appendHtml += html;
                            }
                            $('#newTargetList', parent.document).html(appendHtml + '<br/>');
                        }
                        $('#taskmodalDefault').modal('show');
                    } else {
                        alert('获取已选择的分发目标失败!');
                    }
                }
            })
        },
        /**
         * 展示签发渠道勾选的栏目
         * @param obj
         * @param reason
         */
        showColumn: function(obj, reason) {
            var thisObj = $(obj);
            var timer = null,
                popBox = thisObj.next(),
                imgtop = thisObj.offset().top,
                imgLeft = thisObj.position().left;
            var maxTop = $(window).height() - 240,
                theadTop = $('.fixed-table-header').offset().top + 155,
                boxWidth = $(".popover-box").outerWidth(),
                arrowWidth = $(".popover-arrow").outerWidth();
            var boxLeft = imgLeft - boxWidth * 0.85;
            console.log("imgtop:" + imgtop + " maxTop:" + maxTop + " theadTop:" + theadTop);
//            thisObj.next().css('left', boxLeft + 'px');
            thisObj.next().find('.popover_content').html("栏目 : "+reason);
            $(".popover-box").hide();
            popBox.show();
            thisObj.on("mouseout", function() {
                timer = setTimeout(function() {
                    popBox.hide();
                }, 500);
            });
            thisObj.prev().on("mouseout", function() {
                timer = setTimeout(function() {
                    popBox.hide();
                }, 500);
            });
            $(".popover-box").on("mouseover", function() {
                clearTimeout(timer);
                $(this).show();
            }).on("mouseout", function() {
                $(this).hide();
            });
        },
        /**
         * 打开新媒体栏目模态框
         */
        newsModalShow: function(newsColumnId) {
            // 如果无新媒体栏目被选中，取消当前所有被选中节点的选中状态
            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
            if (!topUtil.isNotEmpty(newsColumnId)) {
                treeObj.cancelSelectedNode();
            } else {
                var node = treeObj.getNodeByParam("id", newsColumnId);
                treeObj.cancelSelectedNode(); //先取消所有的选中状态
                treeObj.checkNode(node, true, true); //将指定ID的节点选中
            }
            $('#newsModal').modal('show');
        },

        /**
         * 打开版本管理模态框
         */
        versionmodalShow: function(mainGuid) {
            window.parent.cmedit.ManuscriptSystem.updatePortalStorageExpireTime();
            //加载版本数据
            $("#versionList").html("");
            $(".noVersion").css("display", "block");
            $(".versionContent").html('<span class="vcontDefault">请在右侧选择对比版本</span>');
            $("input[type=checkbox].selectAllVersion").prop("checked", false);
            $("#changeRow").prop("checked", false);
            if (topUtil.isNotEmpty(mainGuid)) {
                topUtil.ajaxRequest({
                    type: "post",
                    async: false,
                    dataType: "json",
                    url: cmedit.global.cmsPath + "ManuscriptMarkController/getManuscriptMarkList",
                    data: {
                        mainGuid: mainGuid
                    },
                    success: function(data) {
                        if (data.status) {
                            $(".noVersion").css("display", "none");
                            var html = template('manuVersionList', data);
                            $("#versionList").html(html);
                            $('#versionModal').modal('show');
                            //为列表复选框绑定事件
                            $(".versionChoose").unbind('click').bind('click', function(event) {
                                thisContext.checkAllSelect();
                                thisContext.compareVersion(event);
                            });
                            //为全选按钮绑定事件
                            $(".selectAllVersion").unbind('click').bind('click', function() {
                                var choose = $("input[type=checkbox].selectAllVersion").prop("checked");
                                if (!choose) { //当前为选中状态
                                    $("input[type=checkbox].versionChoose").prop("checked", false);
                                    thisContext.compareVersion(event);
                                } else { //当前为未选中状态
                                    $("input[type=checkbox].versionChoose").prop("checked", true);
                                    thisContext.compareVersion(event);
                                }
                            });
                        } else {
                            $.notify("获取稿件版本信息失败");
                            $('#versionModal').modal('show');
                        }
                    }
                });
            } else {
                $('#versionModal').modal('show');
            }

        },

        /**
         * 版本对比
         * @param event
         */
        compareVersion: function(event) {
            event.stopPropagation(); //防止事件冒泡
            var chooseVersions = $("input[type=checkbox]:checked.versionChoose");
            var count = chooseVersions.length;
            if (count >= 1) { //不止一个版本被选中时 【2018-2-11修改：选中一个版本时也要显示】
                var markGuids = [];
                var markVersions = [];
                var markColors = [];
                $.each(chooseVersions, function(index, item) {
                    var markGuid = $(item).parent().attr("id");
                    markGuids.push(markGuid);
                    markVersions.push($("#" + markGuid + " #markVersion").val());
                    markColors.push($("#" + markGuid + " #markColor").val());
                });
                topUtil.ajaxRequest({
                    type: "post",
                    async: false,
                    dataType: "json",
                    url: cmedit.global.cmsPath + "ManuscriptMarkController/compareMark",
                    data: {
                        markGuids: JSON.stringify(markGuids),
                        markVersions: JSON.stringify(markVersions),
                        markColors: JSON.stringify(markColors)
                    },
                    success: function(data) {
                        if (data.status) {
                            $(".versionContent").html(data.data);
                            // 自动换行功能产品ayl要求去除(2018-06-22)
                            $(".versionContent").attr("style", "word-break:break-all;");
                        } else {
                            $.notify(data.msg);
                        }
                    }
                });
            } else {
                $(".versionContent").html('<span class="vcontDefault">请在右侧选择对比版本</span>');
            }
        },
        /**
         * 版本对比结果，自动换行功能
         */
        changeRow: function() {
            if ($("#changeRow").is(':checked')) {
                $(".versionContent").attr("style", "word-break:break-all;");
            } else {
                $(".versionContent").attr("style", "word-break:normal;");
            }

        },
        /**
         * 判断版本对比模态框中的列表 全选状态
         */
        checkAllSelect: function() {
            // 列表数量
            var count = $(".versionChoose").length;
            // 选中的数量
            var chooseCount = $("input[type=checkbox]:checked.versionChoose").length;
            if (count == chooseCount) {
                $(".selectAllVersion").prop("checked", true);
            } else {
                $(".selectAllVersion").prop("checked", false);
            }
        },

        /**
         * 判断左侧tab选中
         */
        isLeftTab: function(mainGuid) {
            setTimeout(function() {
                $('.nav-link').removeClass('nav_active');
                var tabId = $('.myManulistTabs .active').attr('id');
                //如果切换之前的页签是稿件编辑页签，那么取消自动保存定时器
                if (tabId == 'li_list' || tabId == 'li_manuTask' || tabId == 'li_manuSend' || tabId == 'li_manuDownload' ||
                    tabId == 'li_manuSendTask' || tabId == 'li_manuRecycle') {
                    thisContext.clearAutoMenu();
                } else {
                    var son = window.top.document.getElementById('iframe_' + mainGuid).contentWindow;
                    son.cmedit.EditSystem.initSaveAuto(mainGuid);
                }
                leftType = resourceType;
                if (tabId == 'li_list') {
                    if ($("#li_list").hasClass("myManulist")) {
                        $(".myManu").addClass("nav_active");
                        $('#manulistTable').bootstrapTable('refresh');
                    } else {
                        $(".allManu").addClass("nav_active");
                        $('#manulistTable').bootstrapTable('refresh');
                    }
                } else if (tabId == 'li_manuTask') {
                    $("a[name='3']").addClass("nav_active");
                    var childIframe = $('#iframe_manuTask')[0].contentWindow;
                    childIframe.cmedit.TaskSystem.refresh();
                } else if (tabId == 'li_manuSend') {
                    $("a[name='4']").addClass("nav_active");
                    var childIframe = $('#iframe_manuSend')[0].contentWindow;
                    childIframe.cmedit.TargetSystem.refresh();
                } else if (tabId == 'li_manuDownload') {
                    $("a[name='5']").addClass("nav_active");
                    var childIframe = $('#iframe_manuDownload')[0].contentWindow;
                    childIframe.cmedit.DownloadSystem.refresh();
                } else if (tabId == 'li_manuSendTask') {
                    $("a[name='6']").addClass("nav_active");
                    var childIframe = $('#iframe_manuSendTask')[0].contentWindow;
                    childIframe.cmedit.TargetManager.refresh();
                } else if (tabId == 'li_manuRecycle') {
                    $("a[name='7']").addClass("nav_active");
                    var childIframe = $('#iframe_manuRecycle')[0].contentWindow;
                    childIframe.cmedit.RecycleSystem.refresh();
                }
            }, 200);

        },
        /**
         * 重置页签数组
         */
        tablistChange: function(addGuid) {
            tabActivelist.splice($.inArray('new', tabActivelist), 1);
            tabActivelist.push(addGuid);
        },
        //更新门户redis存储信息过期时间
        updatePortalStorageExpireTime: function() {
            if (cmedit.global.isPublish) {
//                $.updateStorageExpireTime();
            }
        },
        /**
         * 设置预览的版本，360px 320px
         * @param width
         */
        setPhoneSize: function(width) {
            var height = width * 658 / 360;
            if (width == 360) {
                height = 658;
                $('#manuscriptPreview_contentAll', window.top.document).css("height", 501);
                $('#manuscriptPreview_contentAll', window.top.document).css("top", '97px');
                $('#setPhone_div', window.top.document).css("margin-left", '-21px');
            } else if (width == 320) {
                height = 587;
                $('#manuscriptPreview_contentAll', window.top.document).css("height", 447);
                $('#manuscriptPreview_contentAll', window.top.document).css("top", '87px');
                $('#setPhone_div', window.top.document).css("margin-left", '-61px');
            }
            $('#manuscriptPreview_bgi', window.top.document).css("width", width);
            $('#manuscriptPreview_bgi', window.top.document).css("height", height);
            $('#manuscriptPreview_contentAll', window.top.document).css("width", width);
            $('#manuscriptPreview div[name="webContent"] p img', window.top.document).each(function() {
                if (!$(this).attr("data-width") && !$(this).attr("data-wxsrc") && !$(this).attr("data-id")) {
                    if ($(this).width() > 319 || imgList[$(this).attr("src")] != null) {
                        thisContext.setWidthHeight(this);
                    }
                }
            });

        },
        /**
         * 图片加载失败方法
         * @param imgObj
         */
        getFail: function(imgObj) {
            var webContentWidth = '';
            webContentWidth = $('#manuscriptPreview div[name="webContent"]', window.top.document).outerWidth();
            $(imgObj).attr('alt', '');
            $(imgObj).css('width', '92%');
            $(imgObj).css('height', $(imgObj).outerWidth());
        },
        /**
         * 图片等比例缩放图片
         * @param imgObj
         * @param type 稿件类型
         */
        setWidthHeight: function(ImgD) { //参数(图片,允许的宽度,允许的高度)
            var iwidth = 0;
            var iheight = 2000;
            iwidth = $('#manuscriptPreview div[name="webContent"]', window.top.document).outerWidth();
            var src = $(ImgD).attr("src");
            var imgwidth = 0;
            var imgheight = 0;
            if (imgList[src] == null) {
                imgwidth = $(ImgD).outerWidth();
                imgheight = $(ImgD).outerHeight();
                imgList[src] = imgwidth + "," + imgheight;
            } else {
                var wh = imgList[src].split(",");
                imgwidth = wh[0];
                imgheight = wh[1];

            }
            if (imgwidth > 0 && imgheight > 0) {
                if (imgwidth / imgheight >= iwidth / iheight) {
                    if (imgwidth > iwidth) {
                        //        				   $(ImgD).attr("style", "width:"+iwidth+";height:"+((imgheight*iwidth)/imgwidth)+"px");
                        $(ImgD).attr("width", iwidth + "px");
                        $(ImgD).attr("height", ((imgheight * iwidth) / imgwidth) + "px");
                    } else {
                        //        				   $(ImgD).attr("style", "width:"+imgwidth+"px;height:"+imgheight+"px");
                        $(ImgD).attr("width", imgwidth + "px");
                        $(ImgD).attr("height", imgheight + "px");
                    }
                } else {
                    if (imgheight > iheight) {
                        //        				   $(ImgD).attr("style", "width:"+((imgwidth*iheight)/imgheight)+"px;height:"+iheight+"px");
                        $(ImgD).attr("width", ((imgwidth * iheight) / imgheight) + "px");
                        $(ImgD).attr("height", iheight + "px");
                    } else {
                        //        				   $(ImgD).attr("style", "width:"+imgwidth+"px;height:"+imgheight+"px");
                        $(ImgD).attr("width", imgwidth + "px");
                        $(ImgD).attr("height", imgheight + "px");
                    }
                }
            }
        },
        /**
         * 浏览器页签关闭时，全部解锁功能
         */
        unLockAll: function() {
            $.ajax({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "ManuscriptMainController/unlockManuscriptByUserId",
                beforeSend: function(XHR) {
                    XHR.setRequestHeader("userId", encodeURIComponent(userId));
                    XHR.setRequestHeader("tenantId", tenantId);
                    XHR.setRequestHeader("token", token);
                    XHR.setRequestHeader("userName", encodeURIComponent(userName));
                },
                success: function(data) {
                    if (data.status) {
                        return;
                    } else {
                        return;
                    }
                }
            });
        },
        /**
         * 路径选择切换
         */
        downRouteChange: function(e) {
            //        	e.stopPropagation();
            // 指定路径下载时
            if ($(e).find('input').val() == 1) {
                // 显示下载目标下拉框
                $('.downTarget').show();
                // 显示附件设置
                $('.isDownloadAttachment').show();
                // 取消禁用是否下载附件checkbox
                $('#isDownloadAttachment').removeAttr("disabled");
            } else {
                // 隐藏下载目标下拉框
                $('.downTarget').hide();
                // 禁用是否下载附件checkbox
                $('#isDownloadAttachment').attr("disabled", "disabled");
                // 清空启用附件下载复选框并隐藏
                $('#isDownloadAttachment').prop('checked', false);
                $('.isDownloadAttachment').hide();
            }

        },

        /**
         * 下载稿件选择
         * @returns {Boolean}
         */
        selectDownload: function() {
            var choosenList = $('#manulistTable').bootstrapTable('getSelections');
            if (choosenList.length == 0) {
                $.notify("请先选择记录！");
                $('.manuLoader').hide();
                return false;
            } else {
                var mainGuids = [];
                var columnIds = [];
                var mainType = "";
                var params = {};
                for (var i = 0; i < choosenList.length; i++) {
                    mainGuids.push(choosenList[i].mainGuid);
                    columnIds.push(choosenList[i].mainColumnId);
                    mainType = choosenList[i].mainType;
                }
                params["mainGuids"] = mainGuids;
                params["columnIds"] = columnIds;
                params["mainType"] = mainType;
                thisContext.showDownloadModal(params);
            }
        },

        /**
         * 下载稿件弹窗
         */
        showDownloadModal: function(params) {
            $('#downloadModal').modal('show');
            // 初始化
            $(":radio[name='downRoute'][value='0']").click();
            $(":radio[name='downloadType'][value='1']").prop("checked", "checked");
            $('#isDownloadAttachment').prop('checked', false);
            $('#isDownloadAttachment').attr("disabled", "disabled");
            $("#downloadPathSelect").val('');
            $("#downLoad_mainGuid").val(JSON.stringify(params["mainGuids"]));
            //判断权限中是否有终审浏览权限，如果有，则显示指定路径
            /*if( $.inArray(privilegeInfo,"PID_CMEDIT_FINALCENSOR")&&$.inArray(privilegeInfo,"PID_CMEDIT_EXPORTWORD")){
            	document.getElementById("zhiding").style.display = "none";
            }else{
            	document.getElementById("zhiding").style.display = "block";
            }*/
            // 加载下载路径下拉框
            thisContext.initDownloadPathSelect(params);
        },

        /**
         * 渲染下载路径下拉列表
         * @param mainGuid
         */
        initDownloadPathSelect: function(params) {
            postData = {
                "mainGuids": JSON.stringify(params["mainGuids"]),
                "columnIds": JSON.stringify(params["columnIds"]),
                "mainType": 0
            }

            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "DownloadManageController/getDownloadPathsByColumn",
                data: postData,
                success: function(data) {
                    if (data.status) {
                        var downloadPathList = data.data;
                        $("#downloadPathSelect").html("");
                        $("#downloadPathSelect").append('<option value="">未选取</option>');
                        for (var i = 0; i < downloadPathList.length; i++) {
                            $("#downloadPathSelect").append('<option value="' + downloadPathList[i].downloadPathGuid + '">' + downloadPathList[i].downloadName + '</option>');
                        }
                        $("#downloadPathSelect").selectpicker('refresh');
                    }

                }
            });
        },

        /**
         * 下载稿件
         */
        submitDownload: function() {
            var downRoute = $("input[name='downRoute']:checked").val(); // 路径选择
            var downloadType = $("input[name='downloadType']:checked").val(); // 文件类型 1:word;2:txt
            var isDownloadAttachment = $('#isDownloadAttachment').prop('checked') ? 1 : 0; // 是否下载附件1:是;0:否
            var mainGuid = $("#downLoad_mainGuid").val();
            // 本地下载
            if (downRoute == 0) {
                thisContext.downloadfileLocal(mainGuid, downloadType);
            }
            // 指定路径下载
            else {
                var downloadPathGuid = $("#downloadPathSelect").val(); // 下载路径ID
                if (!cmedit.global.isNotEmpty(downloadPathGuid)) {
                    $.notify("请选择下载目标！");
                    $('.manuLoader').hide();
                    return false;
                } else {
                    $.notify("附件下载中,请去下载监控列表查看");
                    thisContext.downloadFileSpecified(mainGuid, downloadType, downloadPathGuid, isDownloadAttachment);
                }
            }
        },

        /**
         * 本地下载
         * @param mainGuid
         * @param downloadPathType
         */
        downloadfileLocal: function(mainGuid, downloadType) {
            var tenantId = window.localStorage.getItem("tenantId");
            var mainGuids = JSON.parse(mainGuid);
            mainGuids.forEach(function(val, index) {
                    var url = cmedit.global.cmsPath +
                        "DownloadManscriptController/downloadfileLocal?manuscriptMainGuid=" +
                        val +
                        "&downloadType=" +
                        downloadType +
                        "&tenantId=" +
                        tenantId;
                    try {
                        var elemIF = document.createElement("iframe");
                        elemIF.src = url;
                        elemIF.style.display = "none";
                        document.body.appendChild(elemIF);
                    } catch (e) {

                    }

                })
                //        	window.location.href = cmedit.global.cmsPath
                //			+ "DownloadManscriptController/downloadfileLocal?manuscriptMainGuid="
                //			+ mainGuid
                //			+ "&downloadType="
                //			+ downloadType
                //			+ "&tenantId="
                //			+ tenantId;
        },

        //-------------------------------------------------cre资源相关开始---------------------------------------------
        /**
         * 插入cre资源库返回的内容
         * @param data
         */
        creResourceBack: function(data) {
            var iframeId = data.callId;
            var attachmentList = data.attachments;
            var son = window.top.document.getElementById('iframe_' + iframeId).contentWindow;
            son.cmedit.EditSystem.writeCREResourceData(attachmentList);
        },
        //-------------------------------------------------cre资源相关结束----------------------------------------
        //-------------------------------------------------蓝云资源相关开始---------------------------------------------
        /**
         * 插入蓝云资源库返回的内容
         * @param data
         */
        lanResourceBack: function (data) {
        	var iframeId = data.callId;
        	var attachmentList = data.attachments;
        	var son = window.top.document.getElementById('iframe_' + iframeId).contentWindow;
        	son.cmedit.EditSystem.writeLANResourceData(attachmentList);
        },
		/**
          * 插入大观资源库返回的内容
          * @param data
          */
         daguanResourceBack: function (data) {
         	var iframeId = data.callId;
         	var attachmentList = data.attachments;
         	var son = window.top.document.getElementById('iframe_' + iframeId).contentWindow;
         	son.cmedit.EditSystem.writeDGResourceData(attachmentList);
        },
        //-------------------------------------------------蓝云资源相关结束----------------------------------------
        /**
         * 指定路径下载
         * @param mainGuid
         * @param downloadType
         * @param downloadPathGuid
         * @param isDownloadAttachment
         */
        downloadFileSpecified: function(mainGuid, downloadType, downloadPathGuid, isDownloadAttachment) {
            postData = {
                "manuscriptMainGuid": mainGuid,
                "downloadPathGuid": downloadPathGuid,
                "isDownloadAttachment": isDownloadAttachment,
                "downloadType": downloadType
            }

            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "DownloadManscriptController/downloadfileSpecified",
                data: postData,
                success: function(data) {
                    if (data.status) {

                    } else {
                        $.notify(data.msg);
                    }
                }
            });
        },
        /**
         * 关闭CRE资源库页面
         */
        closeCREModalWindow: function() {
            window.parent.document.getElementById('iframeCREResource').contentWindow.close();
            var index = $('#modalCREResource').attr("tabindex");
            $('#modalCREResource').modal('hide');
            $(".modalClose").click();
        },

        /**
         * 关闭蓝云资源库页面
         */
        closeLANModalWindow: function () {
        	window.parent.document.getElementById('iframeLANResource').contentWindow.close();
        	var index = $('#modalLANResource').attr("tabindex");
        	$('#modalLANResource').modal('hide');
        	$(".modalClose").click();
        },
        /**
         * 关闭大观资源库页面
         */
        closeDGModalWindow: function () {
         	window.parent.document.getElementById('iframeLANResource').contentWindow.close();
         	var index = $('#modalLANResource').attr("tabindex");
         	$('#modalLANResource').modal('hide');
         	$(".modalClose").click();
        },
        /**
         * 初始化弹框
         */
        initModel: function() {
            $('#censorPass').prop("checked", "checked");
            $('#submitModal .checkPeople').show();
        },

        /**
         * 删除下载状态记录
         * @param downloadStatusGuid
         */
        delDownlaodResoure: function(downloadStatusGuid) {
            var delFlag = true;
            var mainGuidlist = [];
            /*console.log(flag);*/
            $('#manuscriptDel').dialogBox({
                type: 'correct', //three type:'normal'(default),'correct','error',
                width: 400,
                height: 200,
                hasMask: true, //是否显示遮罩层
                hasClose: true, //是否显示关闭按钮
                hasBtn: true, //是否显示操作按钮，如取消，确定
                autoHide: false,
                zIndex: 99999, //弹出层定位层级
                effect: 'fade',
                title: ' ',
                content: '确定要删除该记录？',
                confirm: function() {
                    var downloadStatusGuids = [];
                    downloadStatusGuids.push(downloadStatusGuid);
                    var postData = {
                        "downloadStatusGuids": JSON.stringify(downloadStatusGuids)
                    };
                    topUtil.ajaxRequest({
                        type: "post",
                        async: true,
                        dataType: "json",
                        url: cmedit.global.cmsPath + "DownloadManageController/deleteDownloadStatus",
                        data: postData,
                        success: function(data) {
                            // 刷新列表
                            var childIframe = $('#iframe_manuDownload')[0].contentWindow;
                            childIframe.cmedit.DownloadSystem.initDownloadStatus();
                        }
                    });

                }
            });

        },

        /**
         * 签发稿件
         */
        distributeTarget: function() {
            var targetSystemIds = [];
            $.each($("input[name='targetCheck']:checked"), function() {
                targetSystemIds.push($(this).attr('id'));;
            });
            var signType = $("#signType").val();
            var son = window.top.document.getElementById(signType).contentWindow;
            if (signType == 'iframe_manuSendTask') {
                son.cmedit.TargetManager.distributeTarget(targetSystemIds);
            } else {
                son.cmedit.EditSystem.distributeTarget(targetSystemIds);
            }
        },
        confirmDistributeMode:function(postData){
        	topUtil.ajaxRequest({
        		type: "post",
        		async: true,
        		url: cmedit.global.cmsPath + 'CmsNewTargetController/batchDistributeToPlatform',
        		contentType: "application/json;charset=UTF-8",
        		dataType: "json",
        		data : JSON.stringify(postData),
        		success: function (data) {
        			if (data.status) {
        				$.notify(data.msg);
        			} else {
        				$.notify(data.msg);
        			}
        		}
        	});
        },
          /**
         * 新增签发稿件确定按钮
         */
        confirmDistributeButton:function(){
            var selectedUlIds=[];
            $.each($("#selectedUl").find(".selectedLi"), function() {
                selectedUlIds.push($(this).attr('mainGuid'));;
            });
            var sendTargetids = [];
            var channelNames = [];
            $.each($("#selectedSendTargetUl").find("input[name='issuedTarget']:checked"), function() {
                sendTargetids.push({
                    "channelId":   $(this).attr('channelId'),
                    "channelName": $(this).attr('channelName'),
                    "channelType": $(this).attr('channelType'),
                    "distrColumn": $(this).attr('distrColumn'),
                    "distrColumnName": $(this).attr('distrColumnName'),
                    "distrMould": isMoudId,
                    "distrCategory":$(this).attr('categoryId'),

                });;
                var columns = window.sessionStorage.getItem("NewsEditingSuite-platform-column-"+$(this).attr('channelId'));
    			if(cmedit.global.isNotEmpty(columns) && !$(this).attr('distrColumn')){
    				channelNames.push($(this).attr('channelName'));
    			}
            });
            console.log("签发目标id",sendTargetids);
            var postData={
                    channelList:sendTargetids,
                     mainGuids:selectedUlIds,
                }
            //存在渠道有栏目但是未勾选的情况
            if(cmedit.global.isNotEmpty(channelNames)){
	            $('#distributeBtn').dialogBox({
	                type: 'correct', //three type:'normal'(default),'correct','error',
	                width: 400,
	                height: 200,
	                hasMask: true, //是否显示遮罩层
	                hasClose: true, //是否显示关闭按钮
	                hasBtn: true, //是否显示操作按钮，如取消，确定
	                autoHide: false,
	                zIndex: 99999, //弹出层定位层级
	                effect: 'fade',
	                title: ' ',
	                content: '<span style="color:red">"'+channelNames+'</span>"未选择栏目是否继续签发',
	                confirm: function () {
	                	thisContext.confirmDistributeMode(postData);
	                },
		            cancel:function(){
		            	thisContext.sendTaskModal3Show('iframe_manuSendTask');
	                }
	            });
            }else{
            	thisContext.confirmDistributeMode(postData);
            }

        },
        showTargetColumnCategory:function(channelId){
            channelnewid=channelId;

            var category;
            if(channelId.indexOf("NewsEditingSuite-platform-column-") != -1 ){
                var str = channelId.split("NewsEditingSuite-platform-column-");
                var columnid = str[1]?str[1]:"";
                category = window.sessionStorage.getItem("NewsEditingSuite-platform-category-"+columnid);
            }else{
                category = window.sessionStorage.getItem("NewsEditingSuite-platform-category-"+channelId);
            }
            if(category != null){
                document.getElementById("distribute_category_li").style.display="inline";
               /* if($("#distribute_category_li").hasClass("active")){
                    thisContext.showTargetCategory(channelId);
                }*/
            }else{
                document.getElementById("distribute_category_li").style.display="none";

            }
            //if($("#distribute_column_li").hasClass("active")){
                thisContext.showTargetColumns(channelId);
            //}
        },
        showTargetColumnCategory01:function(channelId){
            if($("#distribute_column_li").hasClass("active")){
                thisContext.showTargetColumns(channelId);
            }
            var category;
            if(channelId.indexOf("NewsEditingSuite-platform-column-") != -1 ){
                var str = channelId.split("NewsEditingSuite-platform-column-");
                var columnid = str[1]?str[1]:"";
                category = window.sessionStorage.getItem("NewsEditingSuite-platform-category-"+columnid);
            }else{
                category = window.sessionStorage.getItem("NewsEditingSuite-platform-category-"+channelId);
            }
            if(category != null){
                document.getElementById("distribute_category_li").style.display="inline";
                if($("#distribute_category_li").hasClass("active")){
                    thisContext.showTargetCategory(channelId);
                }
            }else{
                document.getElementById("distribute_category_li").style.display="none";
            }
        },
        showTargetTabColumns:function(){
        	var channelId = channelnewid;
        	thisContext.showTargetColumns(channelId);
        },
        
        showTargetTabCategory:function(){
        	var channelId = channelnewid;
        	thisContext.showTargetCategory(channelId);
        },
                // 点击展示分发栏目
        showTargetColumns: function (channelId) {
            var columns;
            if(channelId.indexOf("NewsEditingSuite-platform-column-") != -1 ){
                var str = channelId.split("NewsEditingSuite-platform-column-");
                var columnid = str[1]?str[1]:"";
                columns = window.sessionStorage.getItem("NewsEditingSuite-platform-column-"+columnid);
            }else{
                columns = window.sessionStorage.getItem("NewsEditingSuite-platform-column-"+channelId);
            }
                	if(!cmedit.global.isNotEmpty(columns)){
                		//thisContext.initTree(null);
                		return;
                	}
                	var columnList = JSON.parse(columns);
                    var columnData = new Array();
                if(channelId.indexOf("NewsEditingSuite-platform-column-") != -1 ){
                    var str = channelId.split("NewsEditingSuite-platform-column-");
                    var columnid = str[1]?str[1]:"";
                    var distrcolumn = $("#selectedSendTargetUl").find("input[channelid="+columnid+"]").attr('distrcolumn');
                }else{
                    var distrcolumn = $("#selectedSendTargetUl").find("input[channelid="+channelId+"]").attr('distrcolumn');
                }

                	for (var i = 0; i < columnList.length; i++) {
                		var columnRaw = columnList[i];
                		var column = {
                				"name" : columnRaw.columnName,
                				// pId为""或者0时为父节点
                				"pId" : columnRaw.columnPId == 0 ? "" : columnRaw.columnPId,
                				"id" : columnRaw.columnId
                        };
                        if(columnRaw.columnId == distrcolumn){
                            column.checked = true;
                        }
                		columnData.push(column)
                    };
                if(channelId.indexOf("NewsEditingSuite-platform-column-") != -1 ){
                    var str = channelId.split("NewsEditingSuite-platform-column-");
                    var columnid = str[1]?str[1]:"";
                    thisContext.initTree(columnData,columnid);
                }else{
                    thisContext.initTree(columnData,channelId);
                }
                },
	    // 点击展示签发分类
	    showTargetCategory: function (channelId) {
            var category;
            if(channelId.indexOf("NewsEditingSuite-platform-column-") != -1 ){
                var str = channelId.split("NewsEditingSuite-platform-column-");
                var columnid = str[1]?str[1]:"";
                category = window.sessionStorage.getItem("NewsEditingSuite-platform-category-"+columnid);
            }else{
                category = window.sessionStorage.getItem("NewsEditingSuite-platform-category-"+channelId);
            }
	    	//var category = window.sessionStorage.getItem("NewsEditingSuite-platform-category-"+channelId);
	    	if(!cmedit.global.isNotEmpty(category)){
	    		thisContext.initTree(null);
	    		return;
	    	}
	    	var categoryList = JSON.parse(category);
	    	var categoryData = new Array();
            if(channelId.indexOf("NewsEditingSuite-platform-column-") != -1 ){
                var str = channelId.split("NewsEditingSuite-platform-column-");
                var columnid = str[1]?str[1]:"";
                var categoryId = $("#selectedSendTargetUl").find("input[channelid="+columnid+"]").attr('categoryId');
            }else{
                var categoryId = $("#selectedSendTargetUl").find("input[channelid="+channelId+"]").attr('categoryId');
            }

	    	for (var i = 0; i < categoryList.length; i++) {
	    		var columnRaw = categoryList[i];
	    		var column = {
	    				"name" : columnRaw.categoryName,
	    				// pId为""或者0时为父节点
	    				"pId" : columnRaw.categoryPId == 0 ? "" : columnRaw.categoryPId,
	    				"id" : columnRaw.categoryId
	    		};
	    		if(columnRaw.categoryId == categoryId){
	    			column.checked = true;
	    		}
	    		categoryData.push(column)
	    	}

            if(channelId.indexOf("NewsEditingSuite-platform-column-") != -1 ){
                var str = channelId.split("NewsEditingSuite-platform-column-");
                var columnid = str[1]?str[1]:"";
                thisContext.initTree(categoryData,columnid);
            }else{
                thisContext.initTree(categoryData,channelId);
            }
	    },
        radioTaskDemo:function(strList){
            var str = strList.split("NewsEditingSuite-platform-moulds-");
            var mouId = str[1]?str[1]:"";
            isMoudId=mouId
            // console.log(mouId)
        },
        // 点击展示签发模板
        showTargetDemo: function (columnKey) {
        	var columns = window.sessionStorage.getItem(columnKey);
            if(!cmedit.global.isNotEmpty(columns)){
                return;
            }
            var columnList = JSON.parse(columns);
            var selectedItems = "";
            var selectedItemsDeux = "";
            // if(isShowSendTask){
                columnList.forEach(function (v, k, arra) {
                    selectedItems += '<div class="radio" style="margin-bottom:20px;margin-top:12px" onclick="cmedit.ManuscriptSystem.radioTaskDemo(\'NewsEditingSuite-platform-moulds-' + v.id + '\')"><label>';
                    selectedItems +=  '<input name="optionsRadiosTask" id="optionsRadiosTask" value='+ v.id+ ' type="radio" mouId="'+v.id+'" >';
                    selectedItems +=   ' <span class="sendTaskName">'+v.name+'</span></label></div>'
                    selectedItems +=  ' <div class="radioImg" style="width: 135px;height: 126px;margin: 10px 45px;"><img src='+ v.url+ ' alt="" style="width:100%;height:100%"></div></div>'
                    if(topUtil.isNotEmpty(v.columnList))window.sessionStorage.setItem("NewsEditingSuite-platform-moulds-" + v.channelId,JSON.stringify(v.columnList));
                    // <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                })
            // }else{
                columnList.forEach(function (v, k, arra) {
                    selectedItemsDeux += '<div class="radio" style="margin-bottom:20px;margin-top:12px" onclick="cmedit.ManuscriptSystem.radioTaskDemo(\'NewsEditingSuite-platform-moulds-' + v.id + '\')"><label>';
                    selectedItemsDeux +=  '<input name="optionsRadiosTask" id="optionsRadiosTask" value='+ v.id+ '  type="radio" mouId="'+v.id+'">';
                    selectedItemsDeux +=  ' <span class="sendTaskName">'+v.name+'</span></label></div>'
                    if(topUtil.isNotEmpty(v.columnList))window.sessionStorage.setItem("NewsEditingSuite-platform-moulds-" + v.channelId,JSON.stringify(v.columnList));
                    // <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                })
            // }
            
            $("#sentTaskDemoMore").html(selectedItems);
            $("#sentTaskDemoMoreDeux").html(selectedItemsDeux);
            $('#sentTaskDemoMoreDeux').hide();
            $('#sentTaskDemoMore').show();
            
        	// thisContext.initTree(columnData,channelId);
        },
        pictureDemo:function(){
            $('#iconLess').removeClass('isSendDemo')
            $('#iconMore').addClass('isSendDemo')
            // $(".radio").append('.radioImg');   
            // isShowSendTask=true
            // thisContext.showTargetDemo()
            $('#sentTaskDemoMore').show();
            $('#sentTaskDemoMoreDeux').hide();
        },
        noPictureDemo:function(){
            $('#iconLess').addClass('isSendDemo')
            $('#iconMore').removeClass('isSendDemo')
            $('#sentTaskDemoMoreDeux').show();
            $('#sentTaskDemoMore').hide();

            
            // $('.radioImg').remove()
            // isShowSendTask=false
            // thisContext.showTargetDemo()
        },
        /**
         *  重试下载
         * @param downloadStatusGuid
         * @param manuscriptMainGuid
         * @param downloadPathGuid
         * @param downloadType
         */
        downloadfileSpecifiedRetry: function(downloadStatusGuid, manuscriptMainGuid, downloadPathGuid, downloadType) {
            $('#manuscriptDel').dialogBox({
                type: 'correct', //three type:'normal'(default),'correct','error',
                width: 400,
                height: 200,
                hasMask: true, //是否显示遮罩层
                hasClose: true, //是否显示关闭按钮
                hasBtn: true, //是否显示操作按钮，如取消，确定
                autoHide: false,
                zIndex: 99999, //弹出层定位层级
                effect: 'fade',
                title: ' ',
                content: '确定要下载重试吗？',
                confirm: function() {

                    var postData = {
                        "manuscriptMainGuid": manuscriptMainGuid,
                        "downloadPathGuid": downloadPathGuid,
                        "downloadStatusGuid": downloadStatusGuid,
                        "downloadType": downloadType
                    };
                    topUtil.ajaxRequest({
                        type: "post",
                        async: true,
                        dataType: "json",
                        url: cmedit.global.cmsPath + "DownloadManscriptController/downloadfileSpecifiedRetry",
                        data: postData,
                        success: function(data) {
                            // 刷新列表
                            var childIframe = $('#iframe_manuDownload')[0].contentWindow;
                            childIframe.cmedit.DownloadSystem.initDownloadStatus();
                        }
                    });

                }
            });

        },
        //-------------------------------------------------回收站方法开始---------------------------------------------
        //还原回收站稿件
        restoreManuscript: function(mainGuids) {
            $('#restoreManuscript').dialogBox({
                type: 'correct', //three type:'normal'(default),'correct','error',
                width: 400,
                height: 200,
                hasMask: true, //是否显示遮罩层
                hasClose: true, //是否显示关闭按钮
                hasBtn: true, //是否显示操作按钮，如取消，确定
                autoHide: false,
                zIndex: 99999, //弹出层定位层级
                effect: 'fade',
                title: ' ',
                content: '是否还原稿件？',
                confirm: function() {
                    var postData = {
                        mainGuids: JSON.stringify(mainGuids)
                    }
                    topUtil.ajaxRequest({
                        type: "post",
                        async: true,
                        dataType: "json",
                        url: cmedit.global.cmsPath + "RecycleController/restoreManuscript",
                        data: postData,
                        success: function(data) {
                            if (data.status) {
                                $.notify("稿件还原成功");
                                var childIframe = $('#iframe_manuRecycle')[0].contentWindow;
                                childIframe.cmedit.RecycleSystem.initData();
                            } else {
                                $.notify(data.msg);
                            }
                        }
                    });
                }
            });
        },
        //彻底删除回收站稿件
        deleteManuscriptReal: function(mainGuids) {
            $('#restoreManuscript').dialogBox({
                type: 'correct', //three type:'normal'(default),'correct','error',
                width: 400,
                height: 200,
                hasMask: true, //是否显示遮罩层
                hasClose: true, //是否显示关闭按钮
                hasBtn: true, //是否显示操作按钮，如取消，确定
                autoHide: false,
                zIndex: 99999, //弹出层定位层级
                effect: 'fade',
                title: ' ',
                content: '是否彻底删除稿件？',
                confirm: function() {
                    var postData = {
                        mainGuids: JSON.stringify(mainGuids)
                    }
                    topUtil.ajaxRequest({
                        type: "post",
                        async: true,
                        dataType: "json",
                        url: cmedit.global.cmsPath + "RecycleController/deleteManuscriptReal",
                        data: postData,
                        success: function(data) {
                            if (data.status) {
                                $.notify("稿件从回收站删除成功");
                                var childIframe = $('#iframe_manuRecycle')[0].contentWindow;
                                childIframe.cmedit.RecycleSystem.initData();
                            } else {
                                $.notify(data.msg);
                            }
                        }
                    });
                }
            });
        },

        /**
         * 清空回收站 无法还原
         */
        clearRecycleManuscript: function(mainType) {
            $('#restoreManuscript').dialogBox({
                type: 'correct', //three type:'normal'(default),'correct','error',
                width: 400,
                height: 200,
                hasMask: true, //是否显示遮罩层
                hasClose: true, //是否显示关闭按钮
                hasBtn: true, //是否显示操作按钮，如取消，确定
                autoHide: false,
                zIndex: 99999, //弹出层定位层级
                effect: 'fade',
                title: ' ',
                content: '是否要清空回收站？',
                confirm: function() {
                    var postData = {
                        mainType: '0' //CMS稿件
                    }
                    topUtil.ajaxRequest({
                        type: "post",
                        async: true,
                        dataType: "json",
                        url: cmedit.global.cmsPath + "RecycleController/clearManuscriptRecycle",
                        data: postData,
                        success: function(data) {
                            if (data.status) {
                                $.notify("清空回收站稿件成功");
                                var childIframe = $('#iframe_manuRecycle')[0].contentWindow;
                                childIframe.cmedit.RecycleSystem.initData();
                            } else {
                                $.notify(data.msg);
                            }
                        }
                    });
                }
            });
        },

        /**
         * 签发弹框
         */
        sendTaskModal: function(mainGuid, columnId) {
            if (selectIds.length > 0 || topUtil.isNotEmpty(mainGuid)) {
                var columnIds = [];
                var mainGuids = [];
                //判断是单条记录选择的还是勾选的
                if (topUtil.isNotEmpty(mainGuid)) {
                    singleMainGuid = mainGuid;
                    mainGuids.push(mainGuid);
                    columnIds.push(columnId);
                } else {
                    //如果入库开关开启了，那么进行签发的时候要判断，如果选中的稿件中有未入库成功的，则不能进行签发
                    /*if (creImportTaskFlag == 0) {
                        var misStatus;
                        for (var i = 0; i < selectIds.length; i++) {
                            misStatus = $("#" + selectIds[i]).attr("status");
                            if (misStatus != 5) {
                                $.notify("选中的稿件有未入库成功的，不能进行签发");
                                return;
                            }
                        }
                    }*/
                    columnIds = selectColumnIds;
                    mainGuids = selectIds;
                }
                var postData = {
                        columnId: JSON.stringify(columnIds),
                        mainGuid: JSON.stringify(mainGuids),
                    }
                    //获取公共的签发目标
                topUtil.ajaxRequest({
                    type: "post",
                    async: true,
                    dataType: "json",
                    url: cmedit.global.cmsPath + "CmsController/getCmsTargetSystemArr",
                    data: postData,
                    success: function(data) {
                        if (data.status) {
                            var appendHtml = '';
                            var targetList = data.data;
                            if (targetList.length > 0) {
                                for (var i = 0; i < targetList.length; i++) {
                                    appendHtml += '<div class="mt-checkbox-list">' +
                                        '<label class="mt-checkbox mt-checkbox-outline">' +
                                        '<input type="checkbox" name="targetCheck" id="' + targetList[i].creTargetGuid + '">' + targetList[i].creTargetName + '' +
                                        '<span></span>' +
                                        '</label>' +
                                        '</div>';
                                }
                                $("#targetListArr", parent.document).html(appendHtml);

                            } else {
                                $("#targetListArr", parent.document).html("无签发目标");
                            }
                            window.parent.cmedit.ManuscriptSystem.sendTaskModalShow();
                        } else {
                            $.notify(data.msg);
                        }
                    }
                });
            } else {
                $.notify("请选择一条稿件进行签发");
            }
        },
        copyshow: function(obj) {
            var _con = $(obj).siblings(".dropdown-menu");
            $("body").off("click").on("click", function(e) {
                if (!_con.is(event.target) && !$(obj).children().is(event.target) && (_con.has(event.target).length === 0) || _con.find('button').is(event.target)) {
                    $(".moreDropDown").removeClass("showDropDown");
                    _con.removeClass("showDropDown");
                } else {
                    if (_con.is(":hidden")) {
                        $(".showDropDown").removeClass("showDropDown");
                        _con.addClass("showDropDown");
                    };
                }
            });
            return false;
        },
        checkBox: function(obj) {
        	var thisObj = $(obj);
        	var name = thisObj.attr("name");
        	var checked = thisObj.prop("checked");
        	if(name == 'parentCopyMic'){
        		if(checked){
        			thisObj.closest(".showDropDown").find("input[name='childrenCopyMic']").prop("checked",true);
        		}else{
        			thisObj.closest(".showDropDown").find("input[name='childrenCopyMic']").prop("checked",false);
        		}
        	}else if(name == 'childrenCopyMic'){
        		var checkedlength = thisObj.closest(".showDropDown").find("input[name='childrenCopyMic']:checked").length;
        		if(checkedlength ==2){
        			thisObj.closest(".showDropDown").find("input[name='parentCopyMic']").prop("checked",true);
        		}else{
        			thisObj.closest(".showDropDown").find("input[name='parentCopyMic']").prop("checked",false);
        		}
        	}
        },
        /**
         * 复制稿件
         * @param mainGuid 稿件主表id
         * @param mainType 复制目标稿件类型 
         * 【0：CMS稿件 1：微信稿 2：微博稿件 3：电视稿件 4：通稿稿件】
         */
        copyManuscript: function(mainGuid, obj) {
            $(obj).parents(".dropdown-menu").hide();
            var targetTypeList = $(obj).parents(".dropdown-menu").find(".dropmenu-list").find("input:checked");
            var mainType = [];
            if (targetTypeList.length > 0) {
                targetTypeList.each(function(item, value) {
                	if($(value).attr("value")){
                		mainType.push($(value).attr("value"));
                	}
                })
            } else {
                return;
            }
            console.log("mainType", mainType);
            //批量复制为其他类稿件
            topUtil.ajaxRequest({
                type: "post",
                async: true,
                dataType: "json",
                url: cmedit.global.cmsPath + "CmsController/copyManuscriptBatch",
                data: {
                    mainGuid: mainGuid,
                    targetMainType: JSON.stringify(mainType)
                },
                success: function(data) {
                    if (data.status) {
                        thisContext.initData();
                        $.notify(data.msg);
                    } else {
                        $.notify('复制失败');
                    }
                }
            });
            /*if(mainType == 0){
        		// 复制为同类稿件
        		topUtil.ajaxRequest({
    				type: "post",
    				async: true,
    				dataType: "json",
    				url: cmedit.global.cmsPath+"CmsController/copyManuscript",
    				data: {
    					mainGuid : mainGuid
    				},
    				success: function(data) {
    					if(data.status) {
    						var cms = data.data;
    						thisContext.initData();
    						newNotify = $.notify({title:'复制成功[<a class="toCopy" href="javascript:void(0);" onclick="cmedit.ManuscriptSystem.switchtoCopyCms(\''+cms.mainGuid+'\',\''+cms.mainHeader +'\');">查看</a>]',message:''},{delay: '5000'});
    					}else{
    						$.notify('复制失败');
    					}
    				}
    			});
        	}else{
        		// 复制为其他类稿件
        		topUtil.ajaxRequest({
    				type: "post",
    				async: true,
    				dataType: "json",
    				url: cmedit.global.cmsPath+"CmsController/copyManuscriptToOther",
    				data: {
    					mainGuid : mainGuid,
    					targetMainType : mainType
    				},
    				success: function(data) {
    					if(data.status) {
    						thisContext.initData();
    						newNotify = $.notify({title:'复制成功[<a class="toCopy" href="javascript:void(0);" onclick="cmedit.ManuscriptSystem.switchtoCopy(\''+data.data+'\',\''+mainType+'\');">查看</a>]',message:''},{delay: '5000'});
    						
    					}else{
    						$.notify('复制失败');
    					}
    				}
    			});
        	}*/
        },
        /**
         * 跳转到复制的同类稿件
         */
        switchtoCopyCms: function(mainGuid, mainHeader) {
            newNotify.close();
            cmedit.ManuscriptSystem.enterDetail(mainGuid, mainHeader);
        },
        /**
         * 跳转到复制的其他类稿件
         */
        switchtoCopy: function(externalKey, mainType) {
            newNotify.close();
            // 获取指定跳转的稿件前端地址
            var appPath = topUtil.getAppPathByType(mainType);
            var switchHtml = appPath + "?externalKey=" + externalKey;
            //        	window.location.href = switchHtml;  //在本窗口跳转
            window.open(switchHtml); //在新窗口跳转
        },
        /**
         * 打开版本管理模态框
         */
        sendTaskModalShow: function(signType) {
            $("#signType").val(signType);
            $('#sendTaskModal').modal('show');
        },
        sendTaskModal3Show: function(signType) {
            $('#sendTaskModal3').modal('show');
        },
        getAsyncCreTarget: function(){
            var postData = {
            		asyncTargetType: "CMS",
                }
            var isAsync = true;
            topUtil.ajaxRequest({
                type: "post",
                async: false,
                dataType: "json",
                url: cmedit.global.cmsPath + "CreTargetController/getAsyncCreTarget",
                data: postData,
                success: function (data) {
                    if (data.status && data.data.length>0) {
                    	isAsync = false;
                    }
                }
            });
            return isAsync;
        },
        initTree: function (mockData, channelid) {
            //ztree配置
            var setting = {
                check: {
                    enable: true,
                    chkStyle: "radio", //radio:单选；checkbox：复选
                    chkboxType: { "Y": "s", "N": "s" },
                    radioType : "all"
                },
                callback: { 
                    onCheck: function (e, treeId, treeNode) { 
                        console.log('treeNode:'+treeNode + ", treeId:" + treeId + ",e:" + e);
                        // zTree.checkNode(treeNode, !treeNode.checked, true); 
                        if(cmedit.global.isNotEmpty(channelid)){
                        	if(treeNode.checked){
                        		if($("#distribute_column_li").hasClass("active")){
                        			$("#selectedSendTargetUl").find("input[channelid="+channelid+"]").attr('distrcolumn',treeNode.id);
                        			$("#selectedSendTargetUl").find("input[channelid="+channelid+"]").attr('distrcolumnName',treeNode.name);
                        		}
                                var category = window.sessionStorage.getItem("NewsEditingSuite-platform-category-"+channelid);

                            if(category != null){
                                if($("#distribute_category_li").hasClass("active")){
                                    $("#selectedSendTargetUl").find("input[channelid="+channelid+"]").attr('categoryId',treeNode.id);
                                    $("#selectedSendTargetUl").find("input[channelid="+channelid+"]").attr('categoryName',treeNode.name);
                                }
                            }else{
                                if($("#distribute_category_li").hasClass("active")){
                                    $("#selectedSendTargetUl").find("input[channelid="+channelid+"]").attr('distrcolumn',treeNode.id);
                                    $("#selectedSendTargetUl").find("input[channelid="+channelid+"]").attr('distrcolumnName',treeNode.name);
                                }
                            }

                        	}else{
                        		if($("#distribute_column_li").hasClass("active")){
                        			$("#selectedSendTargetUl").find("input[channelid="+channelid+"]").attr('distrcolumn','');
                        			$("#selectedSendTargetUl").find("input[channelid="+channelid+"]").attr('distrcolumnName','');
                        		}
                        		if($("#distribute_category_li").hasClass("active")){
                        			$("#selectedSendTargetUl").find("input[channelid="+channelid+"]").attr('categoryId','');
        							$("#selectedSendTargetUl").find("input[channelid="+channelid+"]").attr('categoryName','');
                        		}
                        	}
                        }
                    } 
                },
                view: {
                    nameIsHTML: true, //允许name支持html				
                    selectedMulti: false,
                    showIcon: false
                },
                edit: {
                    enable: false,
                    editNameSelectAll: false
                },
                data: {
                    simpleData: {
                        enable: true
                    },
                }
            };

            $(document).ready(function () {
                //从服务器读取数据并初始化树形图
                //loadDataFromServer(urlStr);  
                //本例直接从模拟数据dataset.js读取
                loadDataFromLocal();//从本地dataset.js文件读取模拟数据并初始化树形图
            });


            /**
             * 从本地js/dataset.js文件读取模拟数据并初始化树形图
             */
            function loadDataFromLocal() {
                //此处的树节点数据mockData是在本地js/dataSet.js中预先定义的模拟数据
                initThisZtree(mockData);//传入数据,初始化ztree
                // zTreeId ztree对象的id,不需要#
                // searchField 输入框选择器
                // isHighLight 是否高亮,默认高亮,传入false禁用
                // isExpand 是否展开,默认合拢,传入true展开
                fuzzySearch('book', '#keyword', null, true); //初始化模糊搜索方法
            }

            /**
             * 初始化ztree
             * 
             * @param {Object} data
             */
            function initThisZtree(data) {
                //初始化ztree三个参数分别是(jQuery对象,ztree设置,树节点数据)
                var treeObj = $.fn.zTree.init($("#book"), setting, data);
                /* var node = treeObj.getNodeByParam("id", channelid);
                treeObj.selectNode(node); */
                treeObj.expandAll(true);
            }
        },
/*        initTree:function(mockData){
           	//ztree配置
            var setting = {
                check: {
                    enable: true,
                    chkStyle: "checkbox",
                    chkboxType: { "Y": "s", "N": "s" }
                },
                view: {
                    nameIsHTML: true, //允许name支持html				
                    selectedMulti: false,
                    showIcon: false
                },
                edit: {
                    enable: false,
                    editNameSelectAll: false
                },
                data: {
                    simpleData: {
                        enable: true
                    },
                    // simpleData: {
                    //     enable: true,
                    //     idKey: "id",
                    //     pIdKey: "parentId",
                    //     rootPId: "null"
                    // }
                }
        };

            $(document).ready(function(){
                //从服务器读取数据并初始化树形图
                //loadDataFromServer(urlStr);  
                //本例直接从模拟数据dataset.js读取
                loadDataFromLocal();//从本地dataset.js文件读取模拟数据并初始化树形图
            });


            *//**
             * 从本地js/dataset.js文件读取模拟数据并初始化树形图
             *//*
            function loadDataFromLocal(){
                //此处的树节点数据mockData是在本地js/dataSet.js中预先定义的模拟数据
                initThisZtree(mockData);//传入数据,初始化ztree
                // zTreeId ztree对象的id,不需要#
                // searchField 输入框选择器
                // isHighLight 是否高亮,默认高亮,传入false禁用
                // isExpand 是否展开,默认合拢,传入true展开
                fuzzySearch('book','#keyword',null,true); //初始化模糊搜索方法
            }

            *//**
             * 初始化ztree
             * 
             * @param {Object} data
             *//*
            function initThisZtree(data){
                //初始化ztree三个参数分别是(jQuery对象,ztree设置,树节点数据)
                var treeObj = $.fn.zTree.init($("#book"), setting, data); 
                treeObj.expandAll(true);
            }
        },*/
        showCREResource: function() {
            $('#modalCREResource').modal('show');
        },
        showLANResource: function () {
        	$('#modalLANResource').modal('show');
        },
		showDGResource: function () {
         	$('#modalDGResource').modal('show');
        },
        showMobilePreview: function() {
            $('#manuscriptPreview').modal('show');
        },
        /**
         * 稿件自动保存功能
         */
        saveAutoManu: function(mainGuid) {
            thisContext.clearAutoMenu();
            debugger;
            // 启动自动保存定时器
            console.log("稿件自动保存功能启动！！");
            var son = window.top.document.getElementById('iframe_' + mainGuid).contentWindow;
            saveAutoTimer = setInterval(
                function() {
                    son.cmedit.EditSystem.saveManuscript("autoSave")
                },
                parseInt(window.sessionStorage.getItem(cmedit.global.saveInterval)) * 1000);
            window.sessionStorage.setItem("saveAutoTimer", saveAutoTimer);
        },
		playVieo: function (playUrl) {
             // videojs.options.flash.swf = "videojs/video-js.swf";
             var videoObj = videojs('resourcePreview');
 			/*option只是一个参数,function onPlayerReady就是播放器初始化完成时会执行的回调函数*/
 			/* var myPlayer = videojs('resourcePreview',option,function onPlayerReady(){
 				var myPlayer = this;
                 myPlayer.src({src: playUrl, type: "application/x-mpegURL"});
 				this.play();
             });     */
             videoObj.ready(function() {
                 videoObj.play();
              });
             
 
        },
        /**
         * 清除定时器
         */
        clearAutoMenu: function() {
            var saveAutoTimer = window.sessionStorage.getItem("saveAutoTimer");
            if (saveAutoTimer) { //先清除之前的定时器
                clearInterval(saveAutoTimer);
                window.sessionStorage.removeItem("saveAutoTimer");
            }
        },
        
        /**
         * 导出为Excel
         */
        exportToExcel : function(){
        	var chooseCount = $("input[name=subBox]:checked").length;
        	if (chooseCount == 0){
        		$.notify({message:"请至少选择一个导出字段"},{z_index: 99999});
        		return;
        	}
        	
        	$("#exportExcelButton").attr("disabled",true);
//        	thisContext.alertdialog("系统正在努力导出，请稍后...");
        	var queryParams = {};
        	resourceType = resourceType ? resourceType : '1';
            if(resourceType == '1'){
            	exportType = 0;
            }else{
            	exportType = 1;
            }
        	queryParams.resourceType=resourceType;
        	queryParams.mainType=0;
            queryParams.exportType=exportType;
    		var exportFields = "";
    		$.each($("input[name=subBox]:checked"), function (index, item) {
    			exportFields += $(item).attr("value") + ",";
            });
    		queryParams.exportFields = exportFields.substring(0,exportFields.length-1);
        	var choosenList = $('#manulistTable').bootstrapTable('getSelections');
            if (choosenList.length == 0) {
//                $.notify({message:"未勾选指定稿件，按照当前页面筛选条件进行批量查询并导出"},{z_index: 99999});
                if ($('#searchContent').val() != null && $('#searchContent').val() != '') {
                    var title = $('#searchContent').val();
                } else {
                    var title = '';
                }
                if (($('#endTime').val() != null && $('#endTime').val() != '') || ($('#startTime').val() != null && $('#startTime').val() != '')) {
                    var dateranges = $("#startTime").val() + " - " + $("#endTime").val();
                } else {
                    var dateranges = '';
                }
                var states = $("#mainStatus button[class*='active']").attr("states");
                var mainIsOriginal = $("#mainIsOriginal button[class*='active']").attr("states");
                mainIsDeleted = mainIsDeleted ? mainIsDeleted : '1';
                var columnId = $("#preReportColumn").val() != "" ? $("#preReportColumn").val() : "";
            	
            	queryParams.mainIsDeleted=mainIsDeleted;
            	queryParams.userColumnIds=userColumnIds;
            	queryParams.mainHeader=title;
            	queryParams.mainStatus=states;
            	queryParams.columnId=columnId;
                queryParams.dateranges=dateranges;
                queryParams.mainIsOriginal=mainIsOriginal;
                queryParams.currentPage=1;
                queryParams.pageSize=1000;
            } else {
                var selectIds = "";
                for (var i = 0; i < choosenList.length; i++) {
                	selectIds += choosenList[i].mainGuid + ",";
                }
        		queryParams.mainGuids = selectIds.substring(0,selectIds.length-1);
            }
            topUtil.ajaxRequest({
                async: true,
                url: cmedit.global.cmsPath + "ExportController/exportToExcel",
                type: 'POST',
                dataType: "json",
                data: queryParams,
                success: function (data) {
                    if (data.status == true || data.status == 'true') {
                    	var fileName = encodeURI(data.data);
                    	var url = cmedit.global.cmsPath + "ExportCommonController/downloadExcelFile?fileName=" + fileName;
                        thisContext.downloadFile(encodeURI(url));
                    } else {
                        $.notify({message:data.msg},{z_index: 99999});
                    }
                    $("#exportExcelButton").attr("disabled",false);
                }
            });
//            $('#myModal_export').modal('hide');
        },
        
        showExportModal : function(){
        	//清除所有的选择样式
        	$("input[name=checkAll]").prop("checked", false);
            $("input[name=subBox]").prop("checked", false);
        	//为导出模态框全选按钮绑定事件
            $("input[name=checkAll]").unbind('click').bind('click', function () {
                var choose = $("input[name=checkAll]").prop("checked");
                if (!choose) { //当前为选中状态
                    $("input[name=checkAll]").prop("checked", false);
                    $("input[name=subBox]").prop("checked", false);
                } else { //当前为未选中状态
                    $("input[name=checkAll]").prop("checked", true);
                    $("input[name=subBox]").prop("checked", true);
                }
            });
            //为列表复选框绑定事件
            $("input[name=subBox]").unbind('click').bind('click', function (event) {
                thisContext.checkExportAllSelect();
            });
        	$('#myModal_export').modal('show');
        },
        
        checkExportAllSelect : function(){
        	// 列表数量
            var count = $("input[name=subBox]").length;
            // 选中的数量
            var chooseCount = $("input[name=subBox]:checked").length;
            if (count == chooseCount) {
                $("input[name=checkAll]").prop("checked", true);
            } else {
                $("input[name=checkAll]").prop("checked", false);
            }
        },
        downloadFile : function (attachPath) {
        	var $a = document.createElement('a');
            $a.setAttribute("href", attachPath);
            $a.setAttribute("download", "");
            var evObj = document.createEvent('MouseEvents');
            evObj.initMouseEvent( 'click', true, true, window, 0, 0, 0, 0, 0, false, false, true, false, 0, null);
            $a.dispatchEvent(evObj);
        },
        alertdialog : function(msg){
        	$('body').append('<div id="manuscriptDel"></div>');	       
        	$('#manuscriptDel').dialogBox({
                type: 'correct',  //three type:'normal'(default),'correct','error',
                width:400,
                height: 200,
                hasMask: true,  //是否显示遮罩层
                hasClose: false,  //是否显示关闭按钮
                hasBtn: true,  //是否显示操作按钮，如取消，确定
                confirmValue: "确定",
                autoHide: false,
                zIndex: 99999,  //弹出层定位层级
                effect: 'fade',
                title: ' ',
                content: msg,
                confirm: function(){
                	$('#manuscriptDel').remove();
                }
        	}); 
        },
        cbbvResourceBack: function(XTMessageObj) {
            var callId = XTMessageObj.callId;
            var iframeId = callId.split("_");
            var son = window.top.document.getElementById('iframe_' + iframeId[1]).contentWindow;
            son.cmedit.EditSystem.cbbvResourceBack(XTMessageObj);
        },
        empty: null
    };
    return new ManuscriptSystemClass();
})(jQuery, window, document);
//}();
$(cmedit.ManuscriptSystem.init(),
    /**
     * 监听资源库信息
     */
    window.addEventListener('message', function(e) {
        e.stopPropagation();
        var CFBExternalUrl = window.sessionStorage.getItem("CFBExternalUrl");
        /*var HJTaskbaseurl = $("#HJTaskbaseurl").val();
    if(HJTaskbaseurl.indexOf(e.origin)!=-1){
    	var HJMessage = e.data;
        if(isNotEmpty(HJMessage)){
        	//关闭iframe弹框
        	$("#windownbg").remove();
      	  	$("#windown-box").remove();
        	//打开创建稿件弹框
        	showMyModal('','create');
        	//解析数据填入稿件
        	window.localStorage.removeItem("HJMessage");
        	window.localStorage.setItem("HJMessage",HJMessage);
        }
    } else */
        if (CFBExternalUrl.indexOf(e.origin) != -1) {
            var XTMessage = e.data;
            var XTMessageObj = JSON.parse(XTMessage);
            var callId = XTMessageObj.callId;
            var iframeId = callId.split("_");
            if (cmedit.global.isNotEmpty(XTMessage)) {
                //关闭iframe弹框
                $("#windownbg").remove();
                $("#windown-box").remove();
                //回填数据填入稿件
                var son = window.top.document.getElementById('iframe_' + iframeId[1]).contentWindow;
                //.writeXTResourceData(XTMessage);
                son.cmedit.EditSystem.writeXTResourceData(XTMessage);
            }
        }

        /**
         * 监听cre签发操作
         */
        if ("DistributeCompleted".indexOf(e.data) != -1) {
            //检测到签发完成，关闭模态框
            $('#manuscript_bulkIssue').hide();
            $('#bulkIssueIframe').remove();
            $('#box_mask').remove();
            //重新加载数据
            var childIframe = $('#iframe_manuSendTask')[0].contentWindow;
            var activeSendTaskLi = $("#li_manuSendTask");
            if (activeSendTaskLi.hasClass("active")) {
                childIframe.cmedit.TargetManager.initData();
            }
            //关闭编辑页
            var activeLi = $("#li_" + $(window.frames["manuscriptIframe"].document.getElementById("mainGuid")).val());
            if (activeLi.hasClass("active")) {
                activeLi.find("i").trigger("click");
            }
        }

        /**
         * 监听cre签发确定按钮
         */
        if (e.data.hasOwnProperty("targetName")) {
            var determineObj = e.data;
            var taskIdArry = window.sessionStorage.getItem("taskIdArry");
            determineObj["taskIdArry"] = taskIdArry;
            //重新加载数据
            var sendTaskIframe = $('#iframe_manuSendTask')[0].contentWindow; //成品稿库ifream
            var editIframe = window.frames["manuscriptIframe"]; //编辑页ifream
            if (editIframe) {
                var activeEditLi = $("#li_" + $(editIframe.document.getElementById("mainGuid")).val());
                if (activeEditLi.hasClass("active")) {
                    editIframe.cmedit.EditSystem.determineTarget(determineObj);
                }
            }
            if (sendTaskIframe) {
                var activeSendTaskLi = $("#li_manuSendTask");
                if (activeSendTaskLi.hasClass("active")) {
                    sendTaskIframe.cmedit.TargetManager.determineTarget(determineObj);
                }
            }
            window.sessionStorage.setItem("taskIdArry", "");
        }

    }, false));
//$(cmedit.ManuscriptSystem.init());
/*$(manuscriptSystem.init());*/